#include <bits/stdc++.h>
using namespace std;
void change_stream(char* in, char* out) {
  ifstream fin;
  fin.open(in);
  ofstream fout;
  fout.open(out);
  if (fin && fout) {
    freopen(in, "r", stdin);
    freopen(out, "w", stdout);
  }
}
long long a[500], renum[500];
void shift(long long i) {
  long long p = a[i];
  a[i] = a[i + 2];
  a[i + 2] = a[i + 1];
  a[i + 1] = p;
  renum[a[i]] = i;
  renum[a[i + 1]] = i + 1;
  renum[a[i + 2]] = i + 2;
}
void solve() {
  long long n;
  cin >> n;
  pair<long long, long long> s[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s[i] = {a[i], i};
  }
  sort(s, s + n);
  for (long long i = 0; i < n; i++) {
    renum[i] = s[i].second;
    a[renum[i]] = i;
  }
  long long sdv = 0;
  for (long long i = 0; i < n; i++)
    for (long long j = i + 1; j < n; j++)
      if (a[i] > a[j]) sdv++;
  if (sdv % 2) {
    bool flag = false;
    for (long long i = 0; i < n - 1; i++)
      if (s[i].first == s[i + 1].first) {
        swap(a[s[i].second], a[s[i + 1].second]);
        renum[a[s[i].second]] = s[i].second;
        renum[a[s[i + 1].second]] = s[i + 1].second;
        flag = true;
        break;
      }
    if (!flag) {
      cout << "-1\n";
      return;
    }
  }
  vector<long long> ans;
  for (long long i = n - 1; i > 1; i--) {
    while (renum[i] < i) {
      long long l = max(0ll, renum[i] - 1);
      ans.push_back(l);
      shift(l);
    }
  }
  cout << ans.size() << "\n";
  for (long long i : ans) cout << i + 1 << ' ';
  cout << "\n";
}
signed main() {
  change_stream("in", "out");
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long test_count = 1;
  cin >> test_count;
  while (test_count--) solve();
}
