#include<bits/stdc++.h>
using namespace std;
#define int long long int
int solve(){
int n;
cin>>n;
vector<int> a(n);
for(int i = 0; i < n; i++){
a[i] = i+1;
}
for(int i = 0; i < n/2; i++){
swap(a[i], a[n-i-1]);
}
if(n%2 == 1){
swap(a[n/2], a[n/2+1]);
}
for(auto it: a){
cout<<it<<" ";
}
cout << endl;
return 0;
}
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int t;
t = 1;
cin>>t;
while(t--){
solve();
}
return 0;
}