#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    fast;
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n + 1);
        a[0] = 0;
        for (int i = 1; i <= n; i++)
            a[i] = i;
        if (n % 2 == 0)
        {
            for (int i = 1; i < n; i += 2)
                swap(a[i], a[i + 1]);
        }
        else
        {
            for (int i = 1; i < n - 2; i+= 2)
                swap(a[i], a[i + 1]);
            int temp = a[n];
            a[n] = a[n - 1];
            a[n - 1] = a[n - 2];
            a[n - 2] = temp;
        }
        for (int i = 1; i <= n; i++)
            cout << a[i] << " ";
        cout << endl;
    }
}