#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int cases=0;
	cin>>cases;
	vector<int> num;
	for(int i=0;i<cases;i++)
	{
		int temp=0;
		cin>>temp;
		num.push_back(temp);
	}
	vector< vector<int> > result;
	for(int i=0;i<cases;i++)
	{
		vector<int> temp(num[i]);
		if(num[i]%2==0)
		{
			for(int k=0;k<num[i];k++)
			{
				temp[(num[i]-1-k)] = k+1;
			}
		}
		else
		{
			for(int k=0;k<(num[i]-1);k++)
			{
				temp[k] = k+2;
			}
			temp[(num[i]-1)] = 1;
		}
		result.push_back(temp);
		for(int j=0;j<num[i];j++)
		{
			cout<<temp[j]<<" ";
		}
		cout<<endl;
	}
	return 0;
} 
