Fill the grid in any possible way
char h = '1' ; for ( int i = 0 ; i < m ; i ++ ) { a [ 0 ] [ i ] = h ; if ( h == '1' ) { h = '0' ; } else { h = '1' ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( i - 1 < 0 ) { continue ; } if ( a [ i - 1 ] [ j ] == '1' ) { a [ i ] [ j ] = '0' ; } else { a [ i ] [ j ] = '1' ; } } } flag = true ; } if ( ! flag ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { System . out . print ( a [ i ] [ j ] ) ; } System . out . println ( ) ; } } }