#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
int p=2;
while(p<=n)
{
arr[p-2]=p;
p++;
}
arr[n-1]=1;
for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
cout<<endl;
}

return 0;
}