// Bismillahir Rahmanir Raheem
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double dl;
typedef tree< ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define u_b upper_bound
#define l_b lower_bound
#define setpre(n) fixed<<setprecision(n)
#define MOD 1000000007
const double eps = 1e-9;
const double PI = acos(-1);
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; cin >> t;
while(t--){
int n; cin >> n;
if(n & 1){
for(int i = 1; i <= n - 3; ++i){
if(i & 1) cout << i + 1 << ' ';
else cout << i - 1 << ' ';
}
cout << n - 1 << ' ' << n << ' ' << n - 2 << '\n';
}
else{
for(int i = 1; i <= n; ++i){
if(i & 1) cout << i + 1 << ' ';
else cout << i - 1 << ' ';
}
cout << '\n';
}
}
return 0;
}