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

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