#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 <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//#include <atcoder/convolution>
//#include <atcoder/modint> 
//using Modint = atcoder::modint998244353;

using namespace std;
typedef long long ll;

void ex_gcd(ll a, ll b, ll &d, ll &x, ll &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    ex_gcd(b, a % b, d, y, x);
    y -= a / b * x;
  }
}
ll inv(ll a, ll n) {
  ll d, x, y;
  ex_gcd(a, n, d, x, y);
  return d == 1 ? (x % n + n) % (n / d) : -1;
}
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

const int maxn = 505;
const int mod = 998244353;

int a[maxn];
int pos[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int T;
  cin>>T;
  while(T--){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
      scanf("%d",&a[i]);
      pos[a[i]] = i;
    }
    int cur=1;
    vector<int>ans;
    for(int i=n;i>=4;i--){
      if(pos[i]==i)continue;
      if((pos[i]&1)!=cur){
        if(i==4&&pos[4]==3){
          int idx = pos[i];
          swap(a[idx-1], a[idx]);
          cur = 1-cur;
          ans.push_back(idx-1);
          pos[a[idx-1]] = idx-1;
          pos[a[idx]] = idx;
        }
        for(int j=1;j<i;j++){
          if(a[j]!=i&&a[j+1]!=i&&(j&1)==cur){
            swap(a[j], a[j+1]);
            cur = 1 - cur;
            ans.push_back(j);
            pos[a[j]] = j;
            pos[a[j+1]] = j+1;
            break;
          }
        }
      }
      for(int j=pos[i];j<i;j++){
        ans.push_back(j);
        cur = 1-cur;
        swap(a[j], a[j+1]);
        pos[a[j]] = j;
        pos[a[j+1]] = j+1;
      }
    }
    if(n==2){
      if(!(a[1]==1&&a[2]==2)){
        ans.push_back(1);
        cur = 1 - cur;
        swap(a[1], a[2]);
        pos[a[1]] = 1;
        pos[a[2]] = 2;
      }
    } else {
      while(!(a[1]==1&&a[2]==2&&a[3]==3)){
        int tmp = 2 - cur;
        ans.push_back(tmp);
        cur = 1-cur;
        swap(a[tmp], a[tmp+1]);
        pos[a[tmp]] = tmp;
        pos[a[tmp+1]] = tmp+1;
      }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
      if(i)printf(" ");
      printf("%d", ans[i]);
    }
    cout<<endl;
  }
  return 0;
}