Link with Monotonic Subsequence
题号:NC239344
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

First, let's review some definitions. Feel free to skip this part if you are familiar with them.

A sequence a is an increasing (decreasing) subsequence of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements and all elements are in increasing (decreasing) order from the beginning to the end.

A permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example,  is a permutation, but  is not a permutation (2 appears twice in the array) and  is also not a permutation ( but there is 4 in the array).

The problem starts from here.

Link has an array. He is currently learning the longest increasing subsequence algorithm. So he comes up with the following question.

Let the value of a permutation p be , where  is the length of the longest increasing subsequence of p and  is the length of the longest decreasing subsequence of p. For all permutations of length n, which one has the minimum value?

输入描述:

Each test contains multiple test cases. The first line contains the number of test cases .

For each test case, there is only one line, containing an integer .

It is guaranteed that the sum of  over all test cases does not exceed .

输出描述:

For each test case, output a single line containing a permutation of length n.

If there are multiple answers, print any of them.
示例1

输入

复制
3
1
2
3

输出

复制
1
1 2
1 3 2