Matrix Summation#861

Matrix Summation

1 second
122.174 megabytes
Very easy

A n \times n matrix is filled with numbers. BuggyD is analyzing the matrix and wants to find the sums of certain submatrices, i.e., he wants to obtain the result of his queries. The matrix is dynamic, meaning the value of any cell can be changed.

Initially, all cells of the matrix are filled with . Create a program for BuggyD.

Input

The first line contains the number of test cases .

The first line of each test case contains a single integer (1 \le n \le 1024), the size of the matrix.

Then follows a list of commands in one of the three formats:

  • "SET x y num" — Set the value of cell to (0 \le x, y < n).

  • "SUM x_1 y_1 x_2 y_2" — Find the sum of numbers in the rectangle from (x_1, y_1) to (x_2, y_2) inclusive. You may assume x_1 \le x_2 and y_1 \le y_2; the result fits in a signed -bit integer.

  • "END" — Indicates the end of the test case.

Output

For each "SUM" command, output the answer on a separate line. After each test case, print a blank line.

Examples

Example 1

Loading
Loading