#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;
// const ll MOD = 998244353;
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 add(ll &a, ll b) {
    a = (a + b) % MOD;
}

void mul(ll &a, ll b) {
    a %= MOD;
    b %= MOD;
    a = a * b % MOD;
}

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

    vector<vector<vector<int>>> idxs(N + 1, vector<vector<int>>(N + 1));
    for (int k = 1; k <= N; k++) {
        ll sum = 0;
        idxs[k][0].push_back(0);
        for (int i = 0; i < N; i++) {
            sum += A[i];
            sum %= k;
            idxs[k][sum].push_back(i + 1);
        }
    }

    vector<vector<int>> nxt(N + 1, vector<int>(N + 1, -1));
    for (int k = 1; k <= N; k++) {
        for (int rest = 0; rest < k; rest++) {
            for (int j = 0; j + 1 < idxs[k][rest].size(); j++) {
                nxt[idxs[k][rest][j]][k] = idxs[k][rest][j + 1];
            }
        }
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -1));
    auto rec = [&](auto &&rec, int now, int divisor) -> ll {
        if (now == N) return 1;
        if (dp[now][divisor] != -1) return dp[now][divisor];

        ll sum = 0;
        ll res = 0;
        if (nxt[now][divisor] != -1) {
            add(res, rec(rec, nxt[now][divisor], divisor));
            if (nxt[now][divisor] < N) add(res, rec(rec, nxt[now][divisor], divisor + 1));
        }

        return dp[now][divisor] = res;
    };

    ll ans = rec(rec, 0, 1);
    cout << ans << endl;
}

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

    solve();

    return 0;
}
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define ld long double
#define For(i,x,y) for(ll i = (ll)(x);i <= (ll)(y);++i)
#define FOr(i,x,y) for(ll i = (ll)(x);i >= (ll)(y);--i)
#define rep(i,x,y) for(ll i = (ll)(x);i < (ll)(y);++i)
#define fi first
#define se second
#define pa pair<ll,ll>
#define pb push_back
#define y1 y11111111111111
#define debug puts("@@@@@@@@@@@@@@@@@@@")
 
#define cpy(a,b) memcpy(a,b,sizeof(b))
inline ll read()
{
	ll x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}
 
void write(ll x)
{
	if(x < 0) putchar('-'), x= -x;
	if(x > 9)write(x/10);
	putchar(x%10+'0');
}
const ll N=200010;
ll n,a[N];
vector<ll>ans;
bool ok(){
	For(i,1,n-1)if(a[i]>a[i+1])return 0;
	return 1; 
}
void swp(ll i,ll j){
	swap(a[i],a[j]);
	ans.pb(i);
}
int main(){
	ll T=read();
	for(;T--;){
		n=read();	ans.clear();
		For(i,1,n)a[i]=read();
		for(;;){
			if (ok())break; 
			bool fl=0;
			For(i,1,n-1)if(i&1){
				if (a[i]>a[i+1]){
					swp(i,i+1);
					fl=1;
					break;
				}
			}
			if(!fl){
				if(n&1)	swp(n-2,n-1);
				else	swp(n-1,n);
			}
			if (ok())break;
			fl=0;
			For(i,1,n-1)if(!(i&1)){
				if (a[i]>a[i+1]){
					swp(i,i+1);
					fl=1;
					break;
				}
			}
			if(!fl){
				if(n&1) swp(n-1,n);
				else	swp(n-2,n-1);
			}
		}
		cout<<ans.size()<<endl;;
		rep(i,0,ans.size())write(ans[i]),putchar(' ');puts(""); 
	}
}