Given a matrix of n×n, each element is an integer, each time you need to answer the followingquestions: In the upper left corner is (x_1, y_1), and the lower right corner is (x_2, y_2) , which is thelargest number after XOR withkin the sub-matrix . You need to answer its coordinates. Note that the coordinates of the upper left corner of the matrix are (1,1), and the coordinates of the lowerright corner are (n, n).
输入
Input a number n \ (2≤n≤256) in the first line, and the next n lines, the number of n ineach line, represents a matrix A \ (1≤Ai,j≤10^9). Next m line has five numbers in each line x_1, y_1, x_2, y_2, k \ (1≤x_1≤x_2≤n,1≤y_1≤y_2≤n,1≤k≤10^9), which have the same meaning as described above.
In line n+ 2, Input a number m \ (1≤m≤2×10^5), which represents the number of test case to bequeried. Nextmline has five numbers in each line x_1, y_1, x_2, y_2, k, which have the same meaning as described above.
输出
Output m lines, each line has two numbers x, y, separated by a space, which means that in sub-matrix, the largest number after being XORed with k is A_{x,y}. If there are multiple solutions, the onewith the smallest lexicographic order is output, that is, if there are multiple solutions, output x The smallest solution, if there are still multiple solutions, output the smallest solution of y.
样例
标准输入 复制文本 |
4 1 2 3 4 1 2 3 4 9 8 7 6 4 4 9 5 10 2 4 3 4 8 1 1 2 4 10 3 2 4 3 6 1 2 1 4 13 1 2 4 4 12 2 3 2 3 9 1 1 2 2 13 3 1 4 3 11 1 1 4 4 11 1 1 4 4 4 |
标准输出 复制文本 |
3 4 1 4 4 3 1 2 1 3 2 3 1 2 4 1 1 4 3 1 |
来源
SCNUCPC 2020 现场赛