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