Bobo has a matrix of size n×m filled with integers. It is guaranteed that all cells which contain the same value are 4-side connected.
Let's define a jailing J_x of a connected component with value x as minimum-area rectangle (with sides parallel to the matrix sides) that covers all cells of the component.
For each jailing B_x, Jessica would like to find the value of
s(B_x)=∑_B_y∈A∖xf(B_x,B_y)⋅y
where A is the set of all integers in the matrix and
f(B_x,B_y)=⎩⎨⎧0 0 1 the area of intersection of B_x and B_y is 0B_x is completely inside B_y or vice versaOtherwise
The input consists of several test cases terminated by end-of-file. For each test case:
The first line contains two integers n and m -- the size of the matrix.
The second line contains n⋅m integers a_1,1,a_1,2,…,a_1,m, a_2,1,a_2,2,…,a_2,m, …, a_n,1,a_n,2,…,a_n,m, where a_i,j is the value in the i-th row and the j-th column.
For each test case, output an integer denoting the value of ∑_x∈As(x)⊕x, where ⊕ denotes the exclusive-or (XOR) operator.