#include <bits/stdc++.h>
using namespace std;
mt19937 gen(time(0));
bool IS_ONE_TEST = 0;
vector<int> res;
int total = 0;
bool proc(int idx, vector<int> &a) {
  if (!total) return 0;
  res.push_back(idx + 1);
  int temp = a[idx + 2];
  a[idx + 2] = a[idx + 1];
  a[idx + 1] = a[idx];
  a[idx] = temp;
  --total;
  return 1;
}
void solve() {
  int n;
  cin >> n;
  res.clear();
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> b = a;
  total = n * n;
  sort(a.begin(), a.end());
  for (int z = 0; z < n; ++z) {
    for (int i = 0; i + 2 < n; ++i) {
      int mn = min({b[i], b[i + 1], b[i + 2]});
      while (b[i] != mn && proc(i, b)) {
      }
    }
    for (int i = n - 1; i > 1; --i) {
      int mx = max({b[i], b[i - 1], b[i - 2]});
      while (b[i] != mx && proc(i - 2, b)) {
      }
    }
  }
  if (a == b) {
    cout << res.size() << endl;
    for (auto &c : res) cout << c << " ";
    cout << endl;
  } else
    cout << -1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(15);
  int t;
  if (IS_ONE_TEST)
    t = 1;
  else
    cin >> t;
  while (t-- > 0) {
    solve();
  }
}
