#include<bits/stdc++.h>
using namespace std;
const int MAXN=505;
 
int n,p[MAXN];
int opt[MAXN*MAXN],m;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch))(ch=='-')&&(f=-f),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}
 
inline int find(int x){
	for(int i=1;;++i) if(p[i]==x) return i;
}
inline bool do_til(int now,int tar,int &oe){
	int i;bool flag=0;
	if(now==tar) return 1; 
	if(((now-1)&1)==oe&&now>tar) for(i=now,flag=1;i>tar;--i) swap(p[i-1],p[i]),opt[++m]=i-1,oe^=1;
	if(((now)&1)==oe&&now<tar)for(i=now,flag=1;i<tar;++i) swap(p[i],p[i+1]),opt[++m]=i,oe^=1;
	return flag;
}
inline bool randswap(int now,int &oe){
	if(oe){
		if(now&1) swap(p[now+2],p[now+3]),opt[++m]=now+2;
		else swap(p[now+1],p[now+2]),opt[++m]=now+1;
	}else{
		if(now&1) swap(p[now+1],p[now+2]),opt[++m]=now+1;
		else swap(p[now+2],p[now+3]),opt[++m]=now+2;
	}
	oe^=1; 
	return 1;
}
 
inline void solve(){
	int i,oe=1;
	n=read();m=0;
	for(i=1;i<=n;++i) p[i]=read();
//	printf("%d\n",n);
//	for(i=1;i<=n;++i) printf("%d ",p[i]);
	for(i=1;i<=n-2;++i){
		while(!do_til(find(i),i,oe))
			randswap(i-1,oe);
	}
	if(p[n-1]==n-1);
	else if(((n-2)&1)==oe){
		opt[++m]=n-2;
		opt[++m]=n-1;
		opt[++m]=n-2;
		opt[++m]=n-1;
		opt[++m]=n-2;
	}else opt[++m]=n-1;
//	puts("");
	printf("%d\n",m);
	for(i=1;i<=m;++i) printf("%d ",opt[i]);puts("");
}
 
int main(){
//	freopen("data.in","r",stdin);
//	freopen("1.out","w",stdout);
	for(int T=read();T;--T)
		solve();
	return 0;
}
/*
2
5
4 1 2 3 5
10
1 4 3 2 5 6 9 7 8 10
 
*/
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

template< int mod = 1000000007 >
struct ModInt {
	int x;
	ModInt() : x(0) {}
	ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
	ModInt &operator+=(const ModInt &p) {
		if((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p) {
		if((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p) {
		x = (int) (1LL * x * p.x % mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}

	ModInt operator-() const { return ModInt(-x); }
	ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
	ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
	ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
	ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
	bool operator==(const ModInt &p) const { return x == p.x; }
	bool operator!=(const ModInt &p) const { return x != p.x; }

	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while(b > 0) {
			t = a / b;
			swap(a -= t * b, b);
			swap(u -= t * v, v);
		}
		return ModInt(u);
	}

	ModInt pow(int64_t n) const {
		ModInt ret(1), mul(x);
		while(n > 0) {
			if(n & 1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ret;
	}

	friend ostream &operator<<(ostream &os, const ModInt &p) {
		return os << p.x;
	}

	friend istream &operator>>(istream &is, ModInt &a) {
		int64_t t;
		is >> t;
		a = ModInt< mod >(t);
		return (is);
	}

	static int get_mod() { return mod; }
};

// const int mod = 1000000007;
const int mod = 998244353;
using mint = ModInt< mod >;
const int MAX = 300005;

mint fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i;
	}
	finv[MAX-1] = fac[MAX-1].inverse();
	for(int i=MAX-2;i>=1;i--){
		finv[i] = finv[i+1]*(i+1);
		inv[i+1] = fac[i]*finv[i+1];
	}
}

// 二項係数計算
mint COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k]);
}

mint ans = 0;
ll n,m;
unordered_map<int,int> mp[200020];
vector<int> prime;
bool not_prime[MAX];
void era(){
	not_prime[0]=not_prime[1]=1;
	for(int i=2;i*i<MAX;i++){
		if(not_prime[i])continue;
		for(int j=i+i;j<MAX;j+=i){
			not_prime[j]=1;
		}
	}
	for(int i=2;i<MAX;i++)if(not_prime[i] == false)prime.push_back(i);
}
mint dfs(ll now,int cnt,ll ma,mint p){
	// if(mp[now][cnt]){
	// 	return mp[now][cnt];
	// }
	mint ret = p;
	for(ll i=ma+1;i<(int)prime.size();i++){
		ll x = now*prime[i];
		if(x > m)break;
		int c = cnt+1;
		int cc = 1;
		while(x<=m){
			cc++;
			ret += dfs(x,c,i,p*COM(n+cc-2,cc-1));
			x *= prime[i];
			c++;
		}
	}
	// mp[now][cnt]=ret.x;
	// cerr << now << " " << ret << endl;
	return ret;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);

	int n,m;
	cin>>n>>m;
	COMinit();
	mint dp[20][5005];
	dp[0][0]=1;
	for(int i=0;i<19;i++){
		for(int j=0;j<=n;j+=2){
			for(int k=0;k<=m;k++){
				int sum = k + (1<<i)*j;
				if(sum <= m){
					dp[i+1][sum] += dp[i][k] * COM(n,j);
				}
			}
		}
	}	
	cout << dp[19][m] << endl;
}