Solving n-queens problem