#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int) x.size()
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define FOR(i, a, b) for(auto i=(a); i<(b); i++)
#define ROF(i, a, b) for(auto i=(b)-1; i>=(a); i--)
#define F0R(i, n) FOR(i, 0, n)
#define R0F(i, n) ROF(i, 0, n)

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll, ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vpii=vector<pii>;

template<class T> bool ckmin(T&a, const T&b) {return b<a?a=b,1:0;}
template<class T> bool ckmax(T&a, const T&b) {return b>a?a=b,1:0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxN=2e5+10;
const int MOD=1e9+7; 
const ll infLL=1e18;
const ld eps=1e-6;

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int t; cin >> t;
	while(t--){
		int n; cin >> n; 
		vi a(n), ans;
		F0R(i, n) cin >> a[i]; 
		for(int op=0; ; op++){
			bool ok=1;
			F0R(j, n-1) ok&=a[j]<a[j+1]; 
			if(ok) break;
			int j=op%2; 
			while(a[j]<a[j+1]&&j<n-1) j+=2; 
			if(j+1>=n) j-=2; 
			ans.pb(j+1); 
			swap(a[j], a[j+1]); 
		}
		cout << siz(ans) << "\n"; 
		for(auto v:ans) cout << v << ' '; 
		cout << "\n"; 
	}	
	return 0; 
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

void solve(){
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N){
    cin >> A[i];
  }
  vector<int> G=A;
  sort(all(G));
  int cnt = 0;
  vector<int> ans;
  while(G!=A){
    if(cnt%2==0){
      int ch = 0;
      for(int i=0;i+1<N;i+=2){
        if(A[i]>A[i+1]){
          ch = i;
          //break;
        }
      }
      ans.pb(ch);
      swap(A[ch], A[ch+1]);
    }
    else{
      int ch = 1;
      for(int i=1;i+1<N;i+=2){
        if(A[i]>A[i+1]){
          ch=i;
          //break;
        }
      }
      ans.pb(ch);
      swap(A[ch],A[ch+1]);
    }
    cnt++;
  }
  cout << cnt << endl;
  rep(i,sz(ans)){
    if(i) cout << " ";
    cout << ans[i]+1;
  }
  cout << endl;
}

int main(){
  int T; cin >> T;
  while(T--){
    solve();

  }
  return 0;
}
