#include <bits/stdc++.h>
using namespace std;
int N, a[505];
void solve() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> a[i];
	vector<int> ans;
	for (int stp = 1; stp <= N * N; stp++) {
		bool flg = 1;
		for (int i = 2; i <= N && flg; i++) flg &= a[i - 1] < a[i];
		if (flg) break;
		int cur = (stp & 1) ? 1 : 2;
		for (int i = cur; i < N; i += 2)
			if (a[i] > a[i + 1]) cur = i;
		swap(a[cur], a[cur + 1]);
		ans.push_back(cur);
	}
	printf("%lu\n", ans.size());
	for (int i : ans) printf("%d ", i);
	putchar('\n');
}
int main () {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
#endif
	int T; cin >> T;
	while (T--) solve();
    return 0;
}
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

#define mkp make_pair
#define mkt make_tuple
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
template <class T> void chmin(T &a, const T &b) {
    if (a > b) a = b;
}
template <class T> void chmax(T &a, const T &b) {
    if (a < b) a = b;
}

void solve() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    rep(i, N) P[i]--;

    vector<int> output;
    int parity = 0;

    auto operate = [&](int pos) -> void {
        output.push_back(pos);
        swap(P[pos], P[pos + 1]);
        parity ^= 1;
    };

    for (int k = N - 1; k > 0; k--) {
        int now = find(all(P), k) - P.begin();
        while (1) {
            if (now == k && (now == N - 1 || P[now] + 1 == P[now + 1])) break;

            if (now % 2 == parity) {
                operate(now);
                now++;
            } else {
                if (now - 1 >= 0) {  // operate twice
                    operate(now - 1);
                    now--;

                    operate(now + 1);
                } else {  // corner case
                    if (k != 1) {
                        operate(now + 1);
                    } else {  // manual operation
                        operate(1);
                        operate(0);
                        operate(1);
                        operate(0);
                        operate(1);
                        break;
                    }
                }
            }
        }
    }

    cout << output.size() << "\n";
    rep(i, output.size()) cout << output[i] + 1 << "\n";
}

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

    int T;
    cin >> T;
    rep(i, T) solve();

    return 0;
}
