//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
int arr[505];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	int TC;
	cin>>TC;
	while (TC--){
		cin>>n;
		rep(x,1,n+1) cin>>arr[x];
		
		if (n==2){
			if (arr[1]==2) cout<<1<<endl<<1<<endl;
			else cout<<0<<endl;
			continue;
		}
		
		vector<int> ans;
		
		int par=1;
		rep(x,n+1,4){
			int pos;
			rep(y,1,n+1) if (arr[y]==x) pos=y;
			
			if (pos==x) continue;
			
			if (pos%2!=par){
				if (par==1){
					if (arr[2]==x)
						ans.pub(3),swap(arr[3],arr[4]);
					else 
						ans.pub(1),swap(arr[1],arr[2]);
				}
				else{
					if (arr[3]==x){
						ans.pub(2),swap(arr[2],arr[3]);
						ans.pub(3),swap(arr[3],arr[4]);
						ans.pub(2),swap(arr[2],arr[3]);
					}
					else 
						ans.pub(2),swap(arr[2],arr[3]);
				}
				par^=1;
			}
			
			rep(z,pos,x){
				ans.pub(z),swap(arr[z],arr[z+1]);
				par^=1;
			}
		}
		
		while (arr[1]!=1 || arr[2]!=2 || arr[3]!=3){
			if (par==1) ans.pub(1),swap(arr[1],arr[2]);
			else ans.pub(2),swap(arr[2],arr[3]);
			par^=1;
		}
		
		cout<<sz(ans)<<endl;
		for (auto &it:ans) cout<<it<<" "; cout<<endl;
	}
}
#include <bits/stdc++.h>
using namespace std;
#define      mxx                 1e18
#define      mnn                 -1e18
//#define      int                 long long
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      Ceil(x,y)           ((x+y-1)/y)
#define      sz(s)               (int)s.size()
#define      angle(x)            double(x * acos(-1) / 180.0)
#define      max_3(a,b,c)        max(a, max(b,c))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      MP                  make_pair
#define      flash               cout.flush()
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
constexpr ll MOD = 998244353;
constexpr ll mod = 1e9  + 7;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cerr<<a<<endl;
#define bug2(a,b)  cerr<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cerr<<a<<" "<<b<<" "<<c<<endl;
/*----*/
const ll N=3e6+5;
vector<ll> adj[N];
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll modpow(ll a,ll b,ll m){ll ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
ll nsum(ll num){return (num*(num+1))/2;}
void edge (ll u,ll v) {adj[u].PSB(v) ;adj[v].PSB(u);}
/*------------------START---------------------*/

/*-----*/
void solve(){
   ll n;
   string s;
   cin>>n;
   V<ll> a(n+1),ok(n+1);
   a[0]=ok[0];
   for(ll i=1;i<=n;i++){
    cin>>a[i]; ok[i]=i;
   }
   ll ct=1;
   V<ll> ans;
   for(ll i=1;i<=n*n;i++){
    if(a==ok) break;
    bool ck=false;
      for(ll j=1;j<n;j++){
         if(j%2 == ct%2 && a[j]>a[j+1]){
          ct++; ans.PSB(j); swap(a[j],a[j+1]); ck=true; break;
         }
      }
      if(!ck){
        for(ll j=n-1;j>=0;j--){
           if(j%2 == ct%2){
             ct++;ans.PSB(j); swap(a[j],a[j+1]); break;
           }
        }
      }
   }

   cout<<ans.size()<<endl;
   for(auto it: ans)
    cout<<it<<' ';
   cout<<endl;

   
   


   //cout << fixed << setprecision(10);
}
/*-----*/
//signed main(){
int main(){
   InTheNameOfGod

   ll Test=1;
   cin>>Test;
   while(Test--){
     solve();
    }
  return 0;
}
