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

int main() {
	int  t;
	cin>>t;
	
	while(t--){
	   int n;
	   cin>>n;
	   
	   int b[n];
	   for(int i=0; i<n ;i++)
	   {
	       b[i] = n-i;
	   }
	   
	   if(n%2)
	   {
	       int tmp= b[n/2];
	       b[n/2] = b[n/2-1];
	       b[n/2-1] = tmp;
	   }
	   
	   for(int i=0; i<n ;i++)
	     cout<<b[i]<<" ";
	   cout<<endl;
	}
	
	return 0;
}