Solves n-queens problems