#include <bits/stdc++.h>
using namespace std;
long long n, a[500], g;
vector<long long> v;
void fun(long long i, long long j) {
  if (i == j) return;
  if (j - 2 - i >= 0) {
    v.push_back(j - 2);
    long long x = a[j];
    a[j] = a[j - 1];
    a[j - 1] = a[j - 2];
    a[j - 2] = x;
    fun(i, j - 2);
  }
  if (j - i == 1) {
    if (i + 2 >= n) {
      for (long long i = n - 3; i >= 0; i--) {
        g = 0;
        v.push_back(i);
        long long x = a[i + 2];
        a[i + 2] = a[i + 1];
        a[i + 1] = a[i];
        a[i] = x;
        for (long long i = 1; i < n; i++)
          if (a[i] < a[i - 1]) g = 1;
        if (g == 0) return;
      }
      return;
    }
    v.push_back(i);
    long long x = a[i + 2];
    a[i + 2] = a[i + 1];
    a[i + 1] = a[i];
    a[i] = x;
    v.push_back(i);
    x = a[i + 2];
    a[i + 2] = a[i + 1];
    a[i + 1] = a[i];
    a[i] = x;
  }
}
long long solve() {
  g = 0;
  cin >> n;
  v.clear();
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    long long m = a[i], k = i, f = 0;
    for (long long j = i + 1; j < n; j++) {
      if (a[j] < m) m = a[j], k = j, f = 1;
    }
    if (f == 0) continue;
    fun(i, k);
    if (g) return cout << "-1", 0;
  }
  cout << v.size() << "\n";
  for (auto u : v) cout << u + 1 << " ";
  v.clear();
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
