D. Balanced Permutation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a positive integer $$$n$$$. Call a permutation $$$p$$$ of length $$$k$$$ balanced if there exist an integer $$$x$$$ $$$(1 \leq x \lt k)$$$ such that $$$p_1 + p_2 + \dots + p_x = p_{x+1} + p_{x+2} + \dots + p_k$$$.

Find the lexicographically smallest balanced permutation of length $$$n$$$.

A permutation of length $$$n$$$ is an array that contains $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in an arbitrary order. For example, $$$\{2,5,3,1,4\}$$$ is a permutation of length $$$5$$$, while $$$\{1,2,2\}$$$ and $$$\{1,3,4\}$$$ are not permutations of length $$$3$$$.

A permutation $$$p$$$ is lexicographically smaller than a permutation $$$q$$$ of the same length if $$$p_a \lt q_a$$$ where $$$a$$$ is the smallest integer such that $$$1 \leq a \leq |p|$$$ and $$$p_a \neq q_a$$$. For example, $$$\{1,2,3,4\}$$$ is lexicographically smaller than $$$\{1,4,2,3\}$$$ since $$$a = 2$$$ and $$$p_2 = 2 \lt 4 = q_2$$$.

Input

The first line contains a positive integer $$$t$$$ ($$$1 \leq t \leq 300$$$) — the number of test cases.

The only line for each test case contains an integer $$$n$$$ ($$$3 \leq n \leq 2 \cdot 10^5$$$) — the length of the permutation. It is guaranteed that $$$n$$$ is chosen in such a way that there always exists at least one balanced permutation of length $$$n$$$.

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

Output

For each test case, output a line containing $$$n$$$ integers $$$p_1,p_2,\dots,p_n$$$ — the lexicographically smallest balanced permutation.

Example
Input
4
3
4
7
8
Output
1 2 3 
1 4 2 3 
1 2 4 7 3 5 6 
1 2 3 4 8 5 6 7 
Note

For the first test case, the permutation $$$\{1,2,3\}$$$ is balanced, since $$$p_1 + p_2 = p_3$$$. Since this is also the lexicographically smallest permutation of length $$$3$$$, the lexicographically smallest balanced permutation of length $$$3$$$ is $$$\{1,2,3\}$$$.

For the second test case, it can be proven that $$$\{1,2,3,4\},\{1,2,4,3\},\{1,3,2,4\},\{1,3,4,2\}$$$ are all not balanced. It can also be proven that $$$\{1,4,2,3\}$$$ is balanced.