#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
#define pq(T) priority_queue<T,vector<T>,greater<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  double ans = 1;
  rep(i,1,n) {
    ans *= i+1;
    ans /= i;
    if (i != n-1) ans += 1;
  }
  printf("%.10lf\n", ans);
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(i = 0; i < n; i++)
bool dfs(vector<int> &p, int swapFlag, int dep, vector<int> &ans) {
	int n = min(4, (int)p.size());
	int i;
	
	rep(i, n) if (p[i] != i) break;
	if (i == n) return true;
	if (dep >= n * n) return false;
	
	rep(i, n - 1) {
		if (i % 2 != swapFlag % 2) { continue; }
		swap(p[i], p[i + 1]);
		ans.push_back(i);
		bool res = dfs(p, !swapFlag, dep + 1, ans);
		if (res) return true;
		swap(p[i], p[i + 1]);
		ans.pop_back();
	}
	return false;
}

vector<int> solve(vector<int> p) {
	int n = p.size();
	int i, j;
	int cnt = 0;
	vector<int> ret;
	
	for (i = n; i >= 5; i--) {
		rep(j, i) if (p[j] == i - 1) break;
		int pos = j;
		if (pos == i - 1) continue;
		if (pos % 2 != cnt % 2) {
			rep(j, i - 1) {
				if (j != pos && j + 1 != pos && j % 2 == cnt % 2) {
					break;
				}
			}
			swap(p[j], p[j + 1]);
			cnt++;
			ret.push_back(j);
		}
		for (j = pos; j + 1 < i; j++) {
			swap(p[j], p[j + 1]);
			cnt++;
			ret.push_back(j);
		}
	}
	dfs(p, cnt % 2, 0, ret);
	return ret;
}

int main() {
	int T, i;
	
	cin >> T;
	while (T--) {
		int n;
		cin >> n;
		vector<int> p(n);
		rep(i, n) { cin >> p[i]; p[i]--; }
		
		vector<int> ans = solve(p);
		
		cout << ans.size() << endl;
		rep(i, ans.size()) {
			cout << ans[i] + 1;
			if (i + 1 < ans.size()) cout << " ";
		}
		cout << endl;
	}
	return 0;
}
