P17442 [CodeChef] INDIPERM
普及-
题目描述

You are given an integer N. Construct an array P of size N such that:

P is a permutation of the first N natural numbers, i.e, each integer $1, 2, 3, \ldots N$ occurs exactly once in P. For example, [1, 3, 2] is a permutation of size 3, but [1, 3, 4] and [2, 1, 2] are not.
P is indivisible. P is said to be indivisible if i does not divide P_{i} for every index 2 ≤ i ≤ N.

It can be proven that under the given constraints, there always exists an indivisible permutation. If there are multiple, you may print any of them.

------ Input Format ------

  • The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains a single integer N, denoting the size of the indivisible permutation you must construct.

------ Output Format ------

  • For every test case, print a single line containing N space-separated integers. These integers must form an indivisible permutation.

------ Constraints ------

$1 ≤ T ≤ 600$
$2 ≤ N ≤ 10^{5}$
- Sum of $N$ over all test cases does not exceed $2 \cdot 10^{5}$

----- Sample Input 1 ------
4
2
3
4
5
----- Sample Output 1 ------
2 1
1 3 2
1 3 4 2
4 5 2 3 1
----- explanation 1 ------
- For the last test case:
- $P_{2} = 5$ is not divisible by $2$
- $P_{3} = 2$ is not divisible by $3$
- $P_{4} = 3$ is not divisible by $4$
- $P_{5} = 1$ is not divisible by $5$
- Since $i$ does not divide $P_{i}$ for every index $2≤ i≤ N$, the permutation is indivisible.

输入格式

见题面

输出格式

见题面

样例输入
4 2 3 4 5
样例输出
2 1 1 3 2 1 3 4 2 4 5 2 3 1