modify the solution to N-Queens