#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 8×88 \times 8 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 aa corresponding to it: a=b1b2…b8a = b_1b_2\dots b_8, where bib_i is the column number of the queen in the ii-th row. It is known that the Eight Queens problem has 9292 solutions in total (i.e., 9292 distinct queen strings).

Given a number bb, output the bb-th string. The strings are compared as follows: queen string xx precedes queen string yy if and only if, when xx and yy are viewed as integers, xx is smaller than yy.

Input Format

The first line is the number of test cases nn, followed by nn lines of input. Each test case occupies one line and contains a positive integer b  (1≤b≤92)b\;(1 \le b \le 92).

Output Format

Output nn lines, each line outputting the result corresponding to one input. The output should be a positive integer, the queen string corresponding to bb.

Sample Input

2
1
92

Sample Output

15863724
84136275

Constraints

Time limit: 1s, memory limit: 1024KiB for each test case.