CF1743B.Permutation Value

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

Permutation Value

You are given an integer nn. You have to construct a permutation of size nn.

A permutation is an array where each integer from 11 to ss (where ss is the size of permutation) occurs exactly once. For example, [2,1,4,3][2, 1, 4, 3] is a permutation of size 44; [1,2,4,5,3][1, 2, 4, 5, 3] is a permutation of size 55; [1,4,3][1, 4, 3] is not a permutation (the integer 22 is absent), [2,1,3,1][2, 1, 3, 1] is not a permutation (the integer 11 appears twice).

A subsegment of a permutation is a contiguous subsequence of that permutation. For example, the permutation [2,1,4,3][2, 1, 4, 3] has 1010 subsegments: [2][2], [2,1][2, 1], [2,1,4][2, 1, 4], [2,1,4,3][2, 1, 4, 3], [1][1], [1,4][1, 4], [1,4,3][1, 4, 3], [4][4], [4,3][4, 3] and [3][3].

The value of the permutation is the number of its subsegments which are also permutations. For example, the value of [2,1,4,3][2, 1, 4, 3] is 33 since the subsegments [2,1][2, 1], [1][1] and [2,1,4,3][2, 1, 4, 3] are permutations.

You have to construct a permutation of size nn with minimum possible value among all permutations of size nn.

Input

The first line contains one integer tt (1t481 \le t \le 48) — the number of test cases.

Then, tt lines follow. The ii-th of them contains one integer nn (3n503 \le n \le 50) representing the ii-th test case.

Output

For each test case, print nn integers — the permutation of size nn with minimum possible value. If there are multiple such permutations, print any of them.

Note

In the first example, the permutation [1,4,3,5,2][1, 4, 3, 5, 2] is one of the possible answers; its value is 22.

In the second example, the permutation [4,1,6,2,5,3][4, 1, 6, 2, 5, 3] is one of the possible answers; its value is 22.

Samples

2
5
6
1 4 3 5 2
4 1 6 2 5 3

在线编程 IDE

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