#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main() {
    ll t;
    cin >> t;
    while(t--) {
        ll n;
        cin >> n;
        ll arr[n];
        ll c = 0; 
        for(ll i = n-1; i >= 0; i--) {
            arr[i] = c+1;
            c++;
        }
        if(n%2 != 0) {
            ll temp = arr[n/2];
            arr[n/2] = arr[n/2 + 1];
            arr[n/2 + 1] = temp;
        }
        for(ll i = 0; i < n; i++) {
            cout << arr[i] << " ";
        }
        cout << endl;
    }
    
}