#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0);\
	cin.tie(0);\
	cout.tie(0);
#define in(x) ll x;cin>>x;
#define Endl "\n";
#define F first
#define S second
#define what_is(x) cerr << #x << " is " << x << endl;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

const ll mod = 1e9+7;
class Items {
  public:
	// pair<ll,ll> v;
	ll first;
	ll second;
	ll weight;
	
	Items(ll a,ll b,ll value):weight(value) {
		first=a;
		second=b;
		// weight=value;
	}
	friend bool operator<(const Items &i1,
						  const Items &i2) {
		return i1.weight>i2.weight;
	}
	
};
class FenwickTree {
  private:
	vector<ll> bit;
	ll n;
  public:
	FenwickTree(ll n) {
		this->n=n;
		bit.assign(n,0);
	}
	FenwickTree(vector<ll> &a):FenwickTree(a.size()) {
		for(ll i=0; i<a.size(); i++) {
			add(i,a[i]);
		}
	}
	ll sum(ll r) {
		ll res=0;
		for(; r>=0; r=(r&(r+1))-1) {
			res+=bit[r];
		}
		return res;
	}
	void add(ll idx,ll delta) {
		for(; idx<n; idx = idx|(idx+1)) {
			bit[idx]+=delta;
		}
	}
	
	friend vector<ll> tree(const FenwickTree &f1) {
		return f1.bit;
	}
};
class Segtree {
  public:
	vector<ll> tree;
	ll n;
	
	Segtree(ll n) {
		this->n=n;
		tree.assign(2*n,0);
	}
	
	Segtree(vector<ll> &a):Segtree(a.size()) {
		for(ll i=0; i<a.size(); i++) {
			add(i,a[i]);
			//break;
		}
	}
	
	void add(ll k,ll delta) {
		k+=n;
		tree[k]+=delta;
		for(k/=2; k>=1; k/=2) {
			tree[k]=tree[2*k]+tree[2*k+1];
		}
	}
	
	ll sum(ll a,ll b) {
		a+=n;
		b+=n;
		ll res=0;
		while(a<=b) {
			if(a%2==1) {
				res+=tree[a++];
			}
			if(b%2==0) {
				res+=tree[b--];
			}
			b/=2;
			a/=2;
		}
		return res;
	}
	
};
ll gcd(ll a,ll b){
	if(b==0) return a;
	return(gcd(b,a%b));
}

class Trienode{
public:
    Trienode * arr[26];
    bool iscomplete;
    Trienode(){
        for(ll i=0;i<26;i++){
            arr[i]=nullptr;
        }
        iscomplete=false;
    }
    void add(string str){
        Trienode * temp=this;
        for(ll i=0;i<str.length();i++){
            ll k=str[i]-'a';
            if(temp->arr[k]==nullptr){
                Trienode * n = new Trienode();
                temp->arr[k]=n;
            }
            temp=temp->arr[k];
        }
        temp->iscomplete=true;
    }
    bool search(string str){
        Trienode * temp=this;
        for(ll i=0;i<str.length();i++){
            ll idx=str[i]-'a';
            if(temp->arr[idx]==nullptr) return false;
            temp=temp->arr[idx];
        }
        return (temp!=nullptr && temp->iscomplete);
    }

};


signed main(){

	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin); 
	    freopen("output.txt", "w", stdout);
	#endif
   	ll T;
   	cin>>T;
   	while(T--){
   		ll input;
   		cin>>input;
   		if(input%2==0){
   			ll k=1;
   			for(ll i=1;i<=input/2;i++){
   				cout<<k+1<<" "<<k<<" ";
   				k+=2;
   			}
   		}else{
   			ll k=1;
   			for(ll i=1;i<=(input-1)/2-1;i++){
   				cout<<k+1<<" "<<k<<" ";
   				k+=2;
   			}
   			cout<<input<<" "<<input-2<<" "<<input-1;
   		}
   		cout<<endl;
   	}
	
}