Chessboard problem using dfs