CF1930B.Permutation Printing

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Permutation Printing

You are given a positive integer nn.

Find a permutation^\dagger pp of length nn such that there do not exist two distinct indices ii and jj (1i,j<n1 \leq i, j \lt n; iji \neq j) such that pip_i divides pjp_j and pi+1p_{i+1} divides pj+1p_{j+1}.

Refer to the Notes section for some examples.

Under the constraints of this problem, it can be proven that at least one pp exists.

^\dagger A permutation of length nn is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array), and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).

Input

Each test contains multiple test cases. The first line contains a single integer tt (1t1031 \leq t \leq 10^3) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (3n1053 \leq n \leq 10^5) — the length of the permutation pp.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

Output

For each test case, output p1,p2,,pnp_1, p_2, \ldots, p_n.

If there are multiple solutions, you may output any one of them.

Note

In the first test case, p=[4,1,2,3]p=[4,1,2,3] is a valid permutation. However, the permutation p=[1,2,3,4]p=[1,2,3,4] is not a valid permutation as we can choose i=1i=1 and j=3j=3. Then p1=1p_1=1 divides p3=3p_3=3 and p2=2p_2=2 divides p4=4p_4=4. Note that the permutation p=[3,4,2,1]p=[3, 4, 2, 1] is also not a valid permutation as we can choose i=3i=3 and j=2j=2. Then p3=2p_3=2 divides p2=4p_2=4 and p4=1p_4=1 divides p3=2p_3=2.

In the second test case, p=[1,2,3]p=[1,2,3] is a valid permutation. In fact, all 66 permutations of length 33 are valid.

Samples

2
4
3
4 1 2 3
1 2 3

在线编程 IDE

建议全屏模式获得最佳体验