#include <bits/stdc++.h>
#define endl '\n'
typedef long long ll;
using namespace std;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
const int mod = 1e9 + 7;
const int N = 5e5 + 6;
void Solve() {
int n;
cin >> n;
for (int i = 2 ; i <= n ; i++)
cout << i << " ";
cout << 1 << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
//freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
int tt = 1, testcase = 1;
cin >> tt;
while (tt--) {
//cout<<"Case "<<testcase++<<": ";
Solve();
}
return 0;
}