Fast Matrix Operations#2052

Fast Matrix Operations

5 seconds
64 megabytes
Very easy

There is a matrix containing at most 10^6 elements divided into rows and columns. Each element has coordinates , where 1 \leq x \leq r and 1 \leq y \leq c. Initially, all elements are zero. You need to handle four kinds of operations:

In the above descriptions, submatrix (x_1, y_1, x_2, y_2) includes all elements such that x_1 \leq x \leq x_2 and y_1 \leq y \leq y_2. It is guaranteed that 1 \leq x_1 \leq x_2 \leq r and 1 \leq y_1 \leq y_2 \leq c. After any operation, the sum of all the elements in the matrix will not exceed 10^9.

Input

There are several test cases. The first line of each case contains three positive integers , , , where (1 \leq m \leq 20,000) is the number of operations. Each of the next lines contains a query. The matrix will have at most twenty rows. The input is terminated by end-of-file (EOF). The size of the input file does not exceed KB.

Output

For each type- query, output the sum, minimum, and maximum.

Examples

Example 1

Loading
Loading