Algorithm


A. Special Permutation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given one integer n">n (n>1">n>1�>1).

Recall that a permutation of length n">n is an array consisting of n">n distinct integers from 1">11 to n">n in arbitrary order. For example, [2,3,1,5,4]">[2,3,1,5,4][2,3,1,5,4] is a permutation of length 5">55, but [1,2,2]">[1,2,2][1,2,2] is not a permutation (2">22 appears twice in the array) and [1,3,4]">[1,3,4][1,3,4] is also not a permutation (n=3">n=3�=3 but there is 4">44 in the array).

Your task is to find a permutation p">p of length n">n that there is no index i">i (1≤i≤n">1in1≤�≤�) such that pi=i">pi=i��=� (so, for all i">i from 1">11 to n">n the condition pi≠i">pii��≠� should be satisfied).

You have to answer t">t independent test cases.

If there are several answers, you can print any. It can be proven that the answer exists for each n>1">n>1�>1.

Input

The first line of the input contains one integer t">t (1≤t≤100">1t1001≤�≤100) — the number of test cases. Then t">t test cases follow.

The only line of the test case contains one integer n">n (2≤n≤100">2n1002≤�≤100) — the length of the permutation you have to find.

Output

For each test case, print n">n distinct integers p1,p2,…,pn">p1,p2,,pn�1,�2,…,�� — a permutation that there is no index i">i (1≤i≤n">1in1≤�≤�) such that pi=i">pi=i��=� (so, for all i">i from 1">11 to n">n the condition pi≠i">pii��≠� should be satisfied).

If there are several answers, you can print any. It can be proven that the answer exists for each n>1">n>1�>1.

Example
input
Copy
2
2
5
output
Copy
2 1
2 1 5 3 4

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;

int main(){
  int t;
  cin>>t;
  int n;
  while(t--){
    cin>>n;
    for(int i = 2; i <= n; i++){
      cout<<i<<" ";
    }
    cout<<1<<endl;
  }
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2
2
5

Output

x
+
cmd
2 1
2 1 5 3 4
Advertisements

Demonstration


Codeforcess Solution 1454-A A. Special Permutation ,C++, Java, Js and Python,1454-A

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+