B. grippy
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

We have a matrix with $$$n$$$ rows and $$$m$$$ columns, where all its values are initially set to $$$0$$$.

Additionally, we have $$$q$$$ operations of two types:

$$$*$$$ The first type of operation flips (changes $$$0$$$ to $$$1$$$ and $$$1$$$ to $$$0$$$) an entire row or column.

$$$*$$$ The second type of operation queries the sum of a submatrix.

The top-left corner of the matrix corresponds to position $$$(1, 1)$$$, and the bottom-right corner corresponds to position $$$(n, m)$$$.

Input

The first line contains a natural number $$$t$$$ $$$(1 \le t \le 10^5)$$$, which is the number of cases.

The first line of each case contains three integers $$$n, m, q$$$ $$$(1 \le n, m, q \le 10^5)$$$, where $$$n$$$ is the number of rows, $$$m$$$ the number of columns, and $$$q$$$ the number of operations.

For each query, the first number is $$$1$$$ if a row or column is flipped, or $$$2$$$ if the sum of a submatrix is requested.

If the query is of type $$$1$$$, two more numbers $$$c$$$ and $$$d$$$ are provided. If $$$c = 1$$$, a column will be flipped, and if $$$c = 2$$$, a row will be flipped. Finally, $$$d$$$ corresponds to the index of the row or column that will be flipped, $$$(1 \le d \le n)$$$ or $$$(1 \le d \le m)$$$.

Queries of type $$$2$$$ are given by four numbers $$$a, b, c, d$$$ where $$$(a, b)$$$ represents the top-left corner and $$$(c, d)$$$ the bottom-right corner of the submatrix, $$$(1 \le a \le c \le n)$$$ and $$$(1 \le b \le d \le m)$$$.

It is guaranteed that the total sum of $$$n, m$$$, and $$$q$$$ is less than $$$10^5$$$.

Output

For each query of type $$$2$$$, you must respond with the sum of the specified submatrix.

Example
Input
2
3 5 8
2 1 1 3 5
1 1 3
2 1 1 3 5
1 1 5
2 1 1 3 5
1 1 4
2 1 1 3 5
2 1 2 2 4
3 5 5
2 1 1 1 1
1 2 3
1 1 4
1 1 5
2 1 1 3 4
Output
0
3
6
9
4
0
5