#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define SHOW1d(v,n) {REP(W,n)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {REP(aaa,i){REP(bbb,j)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

typedef long long ll;
typedef pair<ll,ll> P;

template<typename T>
void show_vector(vector<T> v) {
	for (auto ele: v)cout << ele << " " ;cout << endl;
}

template<typename T>
void show_vector(vector<vector<T>> v) {
	for (auto ele: v)show_vector(ele);
}

template<typename T>
void show_vector(vector<vector<vector<T>>> v) {
	for (auto ele: v) {
		show_vector(ele);
		cout << endl;
	}
}

void solve() {
	ll n;cin >> n;
	vector<ll> v(n);
	REP(i, n) cin >> v[i], v[i]--;

	vector<ll> tmp(2 * n);
	REP(i, 2 * n)tmp[i] = i % n;
	vector<ll> ans;
	int cou = 0;
	for (ll now: tmp) {
		// cout << "### " << now << " ###" << endl;
		ll pla;
		REP(i, n) if (v[i] == now) pla = i;
		while(pla != now) {
			// cout << now << " " << pla << endl;
			// show_vector(v);
			if (pla % 2 != cou % 2 && pla - 1 >= 0) {
				ans.PB(pla - 1);
				swap(v[pla - 1], v[pla]);
				pla--;
			}
			else if (pla % 2 == cou % 2 && pla < now) {
				ans.PB(pla);
				swap(v[pla], v[pla + 1]);
				pla++;
			}
			else {
				ans.PB(cou % 2);
				swap(v[cou % 2], v[(cou % 2) + 1]);
				if (pla == cou % 2) pla++;
			}
			cou++;
		}
	}

	while (v.size() > 2 && (v[0] != 0 || v[1] != 1 || v[2] != 2)) {
		ans.PB(cou % 2);
		swap(v[cou % 2], v[(cou % 2) + 1]);
		cou++;
	}

	// cout << "end swap" << endl;

	cout << ans.size() << endl;
	REP(i, ans.size()) cout << ans[i] + 1 << " ";cout << endl;


}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

	ll t;cin >> t;
	REP(i, t)solve();

	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y));
#define chmax(x,y) x = max((x),(y));
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e18;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;


int main(){
    int x;
    cin >> x;
    cout << max(x,0) << endl;
    return 0;
}