Function to print valid matrix
function printMatrix ( arr , n , m ) { place ( arr , n , m ) ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < m ; j ++ ) { document . write ( arr [ i ] [ j ] ) ; } document . write ( " " ) ; } }