#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 1000000007
using pi = pair<int, int>;
ll mod(ll a)
{
    return ((a%N + N)%N);
}
ll mulMod(ll a, ll b)
{
    return mod(mod(a)*mod(b));
}
ll addMod(ll a, ll b)
{
    return mod(mod(a)+mod(b));
}
int main()
{
    int Tst = 1,i;
    cin >> Tst;

    while(Tst--)
    {
        int n;
        cin >> n;
        if(n%2)
        {

            for(i=n;i>= 2;i--)
            {

                if(i==n/2+1)
                {
                    cout <<1<< " ";
                }
                else
                {
                    cout <<i<< " ";
                }
            }
            cout << n/2+1 << endl;
        }
        else
        {

            for(i=n; i>= 1; i--)
            {
                cout << i << " ";
            }
            cout << endl;
        }
    }
}
