#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e6 + 5;

bool taken[N];
vector<int> ans;

vector<int> solve(vector<int> a) {
    ans.clear();
    int n = a.size();

    int i;
    for(i=n-1; i>=3; i-=4) {
        ans.pb(i);
        ans.pb(i-3);
        taken[i] = taken[i-3] = 1;
    }
    if(i == 2) {
        ans.pb(2);
        taken[2] = 1;
    }
    else if(i == 1) {
        ans.pb(1);
        taken[1] = 1;
    }
    else {
        ans.pb(0);
        taken[0] = 1;
    }
    for(int i=0; i<n; i++) {
        if(!taken[i])
            ans.pb(i);
        else
            taken[i] = 0;
    }

    return ans;
}

#ifndef EVAL
int32_t main() {
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
    cin.tie(nullptr)->sync_with_stdio(0);

    int tt;
    cin >> tt;
    while(tt--) {
        vector<int> a;
        int n;
        cin >> n;
        for(int i=1; i<=n; i++) {
            int x;
            cin >> x;
            a.pb(x);
        }

        vector<int> res = solve(a);
        for(auto x : res)
            cout << x << ' ';
        cout << '\n';
    }
    return 0;
}
#endif