//#pragma GCC_OPTIMIZE("ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
using namespace std;

#define pb push_back
#define x first
#define y second
#define all(c) (c).begin(), (c).end()
using ll = long long;
using ld = long double;
using ull = unsigned long long;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t; cin >> t;
    while (t--) {
        int n; 
        cin >> n;
        for (int i = 2; i <= n; ++i) cout << i << " ";
        cout << 1;
        cout << '\n';
    }

    return 0;
}