#t345. 8 皇后
8 皇后
The Eight Queens
Problem Background
Special for beginners, ^_^
Problem Description
Anyone who plays chess knows: a queen can capture any other piece along rows, columns, and diagonals without step limit. How to place 8 queens on the board (an grid) so that none of them can be captured! This is the famous Eight Queens problem.
For a valid placement of the 8 queens, define a queen string corresponding to it: , where is the column number of the queen in the -th row. It is known that the Eight Queens problem has solutions in total (i.e., distinct queen strings).
Given a number , output the -th string. The strings are compared as follows: queen string precedes queen string if and only if, when and are viewed as integers, is smaller than .
Input Format
The first line is the number of test cases , followed by lines of input. Each test case occupies one line and contains a positive integer .
Output Format
Output lines, each line outputting the result corresponding to one input. The output should be a positive integer, the queen string corresponding to .
Sample Input
2
1
92
Sample Output
15863724
84136275
Constraints
Time limit: 1s, memory limit: 1024KiB for each test case.