{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou might have heard of the Eight queens puzzle. It is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal.\u003c/p\u003e\n\u003cp\u003eThe eight queens puzzle is an example of the more general n queens problem of placing n non-attacking queens on an n×n chessboard, for which solutions exist for all natural numbers n with the exception of n\u003d2 and n\u003d3.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input contains several lines. Each line contains one integer N (N \u003c\u003d 10), \u003c/p\u003e\u003cp\u003erepresenting the number of chess queens and the size of chessboard. \u003c/p\u003e\n\u003cp\u003eThe input terminates when N \u003d 0.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output the number of ways to solve the n-queens puzzle."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e1\n8\n5\n0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e1\n92\n10\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"DFS"}}]}