#K41792. Taco Grid Operations

    ID: 26944 Type: Default 1000ms 256MiB

Taco Grid Operations

Taco Grid Operations

You are given an N x N grid initially filled with zeros. Your task is to process Q operations on this grid. There are two types of operations:

  • SET x y v: Set the cell at row x and column y to the value v.
  • QUERY r: Compute and output the sum of all numbers in row r.

For each QUERY operation, output its result on a new line.

Note: Rows and columns are 1-indexed.

Mathematically, if we denote the grid as \(G\) where \(G_{ij}\) is the element at row \(i\) and column \(j\), then for an operation QUERY r, the answer is \(\sum_{j=1}^{N} G_{rj}\).

inputFormat

The first line of input contains two integers N and Q representing the size of the grid and the number of operations.

The following Q lines each contain an operation in one of the following formats:

  • SET x y v — set the cell at row x and column y to v.
  • QUERY r — output the sum of elements in row r.

outputFormat

For each QUERY operation, output the corresponding sum on a new line.

## sample
3 5
SET 1 1 5
SET 2 2 3
QUERY 1
SET 1 3 7
QUERY 1
5

12

</p>