After getting settled in Bangalore Sako plans to rob houses in Bangalore. He plans to rob society one by one.
Consider society as n*m grid where each cell in grid is represented as house. House at i-th row and j-th column contains A[i][j] money.
Sako plans to rob houses which are completely inside rectange and total amount of money he gets is equal to bitwise XOR of each A[i][j] lying inside in this rectangle.
Sako has q queries where each queries has rectangle description. As a description of rectangle you are given four points, x1,y1 and x2,y2 where x1,y1 is top-left corned of rectangle and x2,y2 is bottom-right corner of rectangle.
For each query output the amount of money Sako will get.
INPUT FORMAT
First line contains two integer N and M. ( 1 <= N , M <= 1000)
N lines follows each line contains M integers Integer at i-the line and j-th position indicates amount of money at house i-th row and j-th column (1<=A[i][j]<=10^9)
Then there is single integer Q which is total number of queries ( 1<=Q <=10^6)
Q lines follow and each line represent rectangle description
OUTPUT FORMAT
print Q lines, each line should contain one integer - the answer of that particular query.
NOTE: Index is 1-based and Use Fast I/O to avoid TLE.
The first query has rectangle (1,1) - (2,2)
Houses lying inside this rectangle:
(1,1)
(1,2)
(2,1)
(2,2)
So answer for first query is 0.