#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sp " "
#define all(x) x.begin(),x.end()
#define FastAF ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
template <typename T> // cin >> vector<T>
istream &operator>>(istream &istream, vector<T> &v){for (auto &it : v) cin >> it;return istream;}
template <typename T> // cout << vector<T>
ostream &operator<<(ostream &ostream, const vector<T> &c){for (auto &it : c) cout << it << " ";return ostream;}
int main(){
FastAF
// #ifndef ONLINE_JUDGE
// freopen("D:/Competitive-Programming/Stream/input.txt","r",stdin);
// freopen("D:/Competitive-Programming/Stream/output.txt","w",stdout);
// #endif
int t;cin>>t;
while(t--){
int n;cin>>n;
int i;
vector<int> v;
for(i=1;i<=n;i++){
v.push_back(i);
}
for(int i=1;i<n-1;i+=2){
v[i]^=v[i-1]^=v[i]^=v[i-1];
}
v[n-1]^=v[n-2]^=v[n-1]^=v[n-2];
cout<<v<<endl;
}
return 0;
}