Given an by two dimensional grid containing positive integers values, you have to answer queries.
In the query, you will be given the row and column of a start cell, , and the row and column of an end cell, . It is guaranteed that , and . For each query, you should return the Bitwise OR of the values in all cells satisfying the condition , and .
INPUT FORMAT
The first line contains two integers , and - denoting the number of rows and columns in the grid.
The line among the next lines each contains integers, .
The next line contains an integer () - denoting the number of queries.
The remaining lines each contain integers (, , ) - denoting the coordinates of the start and end cell, respectively.
OUTPUT FORMAT
The output should contain lines, the of them should be the answer to the query.
The first query contains all the values in the grid. Hence, the answer is the bitwise OR of all the values in the grid, which is 15.
The second query contains cell (1, 2) and (1, 3). Hence, the answer to the query is the bitwise OR of 2 and 3, which is 3.