dp [ i , j ] : Stores the bitwise XOR of submatrix having top left corner at ( 0 , 0 ) and bottom right corner at ( i , j )
int [ , ] dp = new int [ N , M ] ; int [ ] med = new int [ N * M ] ; dp [ 0 , 0 ] = mat [ 0 , 0 ] ; med [ 0 ] = dp [ 0 , 0 ] ;