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