#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) a.begin(), a.end()
typedef vector<ll> vll;
#define life ios_base::sync_with_stdio(false);
#define saver cin.tie(0);
#define f first
#define s second
#define nxt cout << endl;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
#define rep(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define rep0(i, a) rep(i, 0, a)
#define pb push_back
int main()
{
life saver int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vll v(n + 1);
for (int i = 1; i <= n; i++)
{
if (i & 1)
v[i] = i + 1;
else
v[i] = i - 1;
}
if (n & 1)
v.back() = n;
swap(v[n - 1], v[n]);
for (int i = 1; i < n + 1; i++)
{
cout << v[i] << " ";
}
cout << endl;
}
return 0;
}