Grids to store the possible grids
gridTest1 = [ [ ' ' for i in range ( 1001 ) ] for j in range ( N ) ] NEW_LINE gridTest2 = [ [ ' ' for i in range ( 1001 ) ] for j in range ( N ) ] NEW_LINE createGrid ( gridTest1 , True , N , M ) NEW_LINE createGrid ( gridTest2 , False , N , M ) NEW_LINE if ( testGrid ( gridTest1 , grid , N , M ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE printGrid ( gridTest1 , N , M ) NEW_LINE DEDENT elif ( testGrid ( gridTest2 , grid , N , M ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE printGrid ( gridTest2 , N , M ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT