#P2117. 小Z的矩阵
小Z的矩阵
Description
Xiao Z has recently become obsessed with matrices. He defines a characteristic function for a special kind of matrix. For an matrix where every element of is or , define $\displaystyle G(A) = \left(\sum_{i = 1}^n\sum_{j = 1}^n A_{i, j}\cdot A_{j, i}\right) \bmod 2$. For example:
$$\begin{pmatrix} 1 & 1 & 1\\ 0 & 1 & 1\\ 1 & 0 & 0\\ \end{pmatrix}$$For the matrix above, $G(A)=(1\times 1+1\times 0+1\times 1+0\times 1+1\times 1+1\times 0+1\times 1+ 0\times 1+0\times 0) \bmod 2 = 0$.
Of course, querying the value of a single matrix is too simple. Along with giving you an matrix, Xiao Z also gives you operations, described as follows:
- Operation 1: of the form
1 x, which means “flip” all elements in row . - Operation 2: of the form
2 x, which means “flip” all elements in column . - Operation 3: an integer
3, which asks for the current value of the characteristic function .
“Flip” means changing to and to .
Input Format
The first line contains two positive integers . is the number of rows (and columns) of the matrix, and is the number of operations.
The next lines describe an matrix , with .
The next lines contain the operations.
Output Format
Output a single line consisting of several numbers with no spaces, representing the result of each operation (no output for operations 1 and 2).
3 12
1 1 1
0 1 1
1 0 0
3
2 3
3
2 2
2 2
1 3
3
3
1 2
2 1
1 1
3
01001
Hint
Constraints
- For of the testdata, , .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号