#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS;
    int t;
    cin>>t;
    while(t--){
		int n;
		cin>>n;
		if(n%2==0){
			for(int i=n; i>0; i--){
				cout<<i<<" ";
			}
		}
		else{
			int mid=(n+1)/2;
			cout<<mid<<" ";
			for(int i=n; i>0; i--){
				if(i==mid) continue;
				cout<<i<<" ";
			}
		}
		cout<<endl;
	}
    return 0;
}
