Second International  Programming Contest
March 28, 2004, Blagoevgrad, Bulgaria
Problem B
The 88 Queens problem
The 8 Queens problem is well known and often used to demonstrate different programming techniques. It was first analyzed in 1850 by Gauss, who defined it as trying to situate eight queens on a standard chessboard 8x8 in a way so that no one threatens another one, as defined by the rules of chess.

Here we will consider a slight deviation from the original problem: the “88 Queens problem”. The rules are the same as in the original one, except that the board is much bigger: up to 88 x88. 

Your task will be to implement an algorithm that can solve the problem for any board of size up to 88. However, to check the correctness we will only want to make sure your implementation works for N < 10000. If so, we will assume the algorithm should in principle be practical on bigger boards as well. 

Given a square board of size NxN (5 N < 10000) the goal is to put N queens so that there are no two ones on the same horizontal, vertical or diagonal. A sample solution for N = 8 is shown on the picture below.

.....

Input
The first line contains the number of tests. Each test is described by a single line: the number N. 

Output
For each test case you should output exactly one line. If there is no solution it should say “NO SOLUTION”. Otherwise, the line should contain N integers R1 R2 … RN separated by a single space, where Ri is the column number of the queen in row i (1 <= i <= N). 

Example

Sample Input file  
2
5
8

Sample Output file
1 3 5 2 4
2 7 3 6 8 5 1 4