Minimum Good Permutation

All submissions for this problem are available.
Read problems statements in mandarin chinese, russian and vietnamese as well.
A permutation of length n is an array of size n consisting of n distinct integers in the range [1, n]. For example, (3, 2, 4, 1) is a permutation of length 4, but (3, 3, 1, 4) and (2, 3, 4, 5) are not, as (3, 3, 1, 4) contains duplicate elements, and (2, 3, 4, 5) contains elements not in range [1,4].
A permutation p of length n is good if and only if for any 1 ≤ i ≤ n, p_{i} ≠ i.
Please find the lexicographically smallest good permutation p.
Definition for "lexicographically smaller":
For two permutations p and q, we say that p is lexicographically smaller than q if and only if there exists a index 1 ≤ l ≤ n such that:
 For any 1 ≤ i < l, p_{i} = q_{i}. Note that if l = 1, this constraint means nothing.
 and, p_{l} < q_{l}.
For example, (2, 3, 1, 4) < (2, 3, 4, 1) < (3, 4, 1, 2). The lexicographically smallest permutation is, of course, (1, 2, ..., n), though this one is not good.
Input
First line of the input contains an integer T denoting number of test cases.
For each test case, the only line contains an integer n.
Output
For each test case, output the lexicographically smallest good permutation of length n. It's guaranteed that this permutation exists.
Constraints
 1 ≤ T ≤ 10
 2 ≤ n ≤ 10^{5}
Subtasks
 Subtask #1 (17 points): 2 ≤ n ≤ 9
 Subtask #2 (83 points): Original Constraints
Example
Input: 4 2 3 5 6 Output: 2 1 2 3 1 2 1 4 5 3 2 1 4 3 6 5
Explanation
Example case 1. The only good permutation of length 2 is (2, 1).
Example case 2. Consider all permutations of length 3, they are(in lexicographically order):
 p = (1, 2, 3), it's not good since p[1] = 1, p[2] = 2 and p[3] = 3;
 p = (1, 3, 2), it's not good since p[1] = 1;
 p = (2, 1, 3), it's not good since p[3] = 3;
 p = (2, 3, 1), it's good since p[1] ≠ 1, p[2] ≠ 2 and p[3] ≠ 3;
 p = (3, 1, 2), it's good since p[1] ≠ 1, p[2] ≠ 2 and p[3] ≠ 3;
 p = (3, 2, 1), it's not good since p[2] = 2.
Thus the minimum good one is (2, 3, 1).
Example case 3. Consider two good permutations for third test case: p=(2, 1, 4, 5, 3) and q=(2, 4, 1, 5, 3), then p < q. You can check lexicographically condition as follows. Find the first index where the entries of two permutations are different, and compare those entries. For example, in this case, the first position where the entries differ is index 2. You can see that p[2] < q[2], as 1 < 4, so p is lexicographically smaller than q.
Author:  r_64 
Tester:  jingbo_adm 
Editorial  https://discuss.codechef.com/problems/MINPERM 
Tags  easy, r_64, sept17 
Date Added:  26072017 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 