/*
* Author: Md. Mahfuzur Rahman
* Purpose: Competitive Programming
*/
#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;
#define ll long long
#define pb push_back
#define endl '\n'
#define nl cout << endl
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define srt(v) sort(v.begin(),v.end())
#define vii vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long,long>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define minheap priority_queue<long long, vector<long long>, greater<long long>>
#define maxheap priority_queue<long long, vector<long long>>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
template <typename... T>
void read(T&... args){((cin>>args), ...);}
template <typename... T>
void write(T... args){((cout<<args<<" "), ...);}
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int MAX = 10000001;
#ifdef ONLINE_JUDGE
#define debug(...) 42
#else
#include "algo/debug.h"
#endif
void solve(int tc)
{
ll n;cin>>n;
if(n%2==0)
{
for(ll i=1;i<n;i+=2){
cout<<i+1<<" "<<i<<" ";
}
cout<<endl;
}
else{
vector<ll>v;
for(ll i=1;i<n;i+=2){
v.pb(i+1);
v.pb(i);
}
ll c=v.back();
v.pop_back();
v.pb(n);
v.pb(c);
for(auto x:v){
cout<<x<<" ";
}
nl;
}
}
int main()
{
FAST_IO;
#ifndef ONLINE_JUDGE
freopen("Error.txt","w",stderr);
#endif
int t = 1;
int tt=1;
cin >> t;
while (t--)
{
solve(tt++);
}
return 0;
}