Solving N-queens puzzle