题目描述
Given an integer $N, find a permutation P = P_{1}, P_{2}, \ldots, P_{N}$ of length N that satisfies the following two conditions:
$P_{i} \neq i (1$ ≤ i ≤ N);
Consider the set which contains P_{i} \% i for all 1 ≤ i ≤ N. This set should have the minimum number of distinct integers possible, over all permutations P.
Note that a permutation of length N is an array containing every integer from 1 to N exactly once.
------ Input Format ------
- The first line will contain T, number of test cases. Then the test cases follow.
- Each test case consists of a single line of input, an integer N, the length of the required permutation.
------ Output Format ------
For each test case, output on a new line, N space-separated integers, denoting the permutation P of length N satisfying the above conditions.
------ Constraints ------
$1 ≤ T ≤ 700$
$2 ≤ N ≤ 10^{5}$
- Sum of $N$ over all test cases does not exceed $2 \cdot 10^{5}$.
------ subtasks ------
Subtask 1 (10 points): $1 ≤ M ≤ 10$
Subtask 2 (20 points): The sum of $N$ across all test cases won't exceed $20$.
Subtask 3 (70 points): No further constraints.
----- Sample Input 1 ------
2
2
3
----- Sample Output 1 ------
2 1
2 3 1
----- explanation 1 ------
Test case $1$: The possible permutations of length $2$ are $[1,2]$ and $[2,1]$. The only permutation that satisfies the conditions is $[2,1]$. The values $P_{i}$ $\%$ $i$ are $[2\%1, 1\%2] = [0, 1]$.
Thus there are $2$ distinct values of $P_{i}$ $\%$ $i$, which is the minimum possible.
Test case $2$: There are $6$ possible permutations of length $3$ out of which $[2,3,1]$ satisfies the above conditions. The values $P_{i}$ $\%$ $i$ are $[2\%1, 3\%2, 1\%3] = [0, 1, 1]$.
Thus there are $2$ distinct values of $P_{i}$ $\%$ $i$, which is the minimum possible.
输入格式
见题面
输出格式
见题面