#include <bits/stdc++.h>
using namespace std;
int main()
{
	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 p = n;
			for(int i=n;i>0;i--)
			{
				if(i==(n/2)+1)
					cout<<1<<" ";
				else
					cout<<p<<" ",p--;
			}
		}
		cout<<endl;
	}
	return 0;
}