#include <bits/stdc++.h>

using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define Interactive_console cin.tie(NULL)
#define ull long long int


int main()
{
    IO;
    ull t,n;
    cin>>t;

    while(t--){
        cin>>n;
        if(n%2==0)
        {   int y=n;
            while(y)
                cout<<y--<<" ";
            cout<<"\n";
        }
        else
        {
            int k=n/2;
            int p=n;
            while(k--)
                cout<<p--<<" ";
            int j=n-n/2;
            for(int i=1;i<=j;i++)
                cout<<i<<" ";
            cout<<"\n";
        }


    }
    return 0;
}
