#P3890. [GDOI2014] 比特矩阵
[GDOI2014] 比特矩阵
Description
Due to the popularity of The Hobbit, L’s roommate X has recently become interested in the currency they use. For this study, X needs to understand something called a bit matrix. Although a bit matrix is still a matrix, its multiplication is a little different from ordinary matrix multiplication.
For bit matrices, means . Here denotes taking bitwise OR over a sequence; for example, means . The symbol means bitwise OR. Bitwise OR views two numbers in binary: if at bit at least one of the two numbers is , then the -th bit of the result is ; otherwise that bit is . The symbol denotes bitwise XOR: if the -th bits of two binary numbers are different, then the -th bit of the result is ; otherwise it is .
Here is an example of bit-matrix multiplication.
$$\begin{bmatrix}1&6\\3&5\end{bmatrix}\times\begin{bmatrix}3&6\\5&7\end{bmatrix}=\begin{bmatrix}3&7\\0&7\end{bmatrix}$$Now X would like you to compute , where is an bit matrix, and is the result of multiplying copies of . Precisely:
- .
- , for .
Input Format
The first line contains two positive integers . The next lines each contain non-negative integers; in these lines, the -th number of the -th line is the element of the bit matrix.
Output Format
Output the bit matrix . That is, print a bit matrix in the same format as the input matrix . See the sample output for details.
2 4
10 5
5 10
0 15
15 0
3 16
6 5 7
5 6 7
7 7 6
0 3 3
3 0 3
3 3 0
Hint
Constraints
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , , and all input integers do not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号