#include <bits/stdc++.h>
using namespace std;
void rotate(vector<int>& a, int at) {
  int x = a[at];
  int y = a[at + 1];
  int z = a[at + 2];
  a[at] = z;
  a[at + 1] = x;
  a[at + 2] = y;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<int> ans;
  int insertAt = 0;
  while (insertAt < n) {
    int lowestIndex = insertAt;
    for (int i = insertAt; i < (n); ++i) {
      if (a[i] < a[lowestIndex]) {
        lowestIndex = i;
      }
    }
    int at = lowestIndex;
    while (at - insertAt >= 2) {
      ans.push_back(at - 2);
      rotate(a, at - 2);
      at -= 2;
    }
    if (at != insertAt) {
      if (at == n - 1) {
        if (a[n - 1] == a[n - 3]) {
          ans.push_back(n - 3);
          rotate(a, n - 3);
          break;
        }
        int duplicate = n - 1;
        while (duplicate > 0 && a[duplicate - 1] != a[duplicate]) {
          duplicate--;
        }
        duplicate--;
        if (duplicate == -1) {
          cout << -1 << endl;
          return;
        } else {
          int steps = 0;
          while (duplicate + 2 != insertAt) {
            ans.push_back(duplicate);
            rotate(a, duplicate);
            duplicate++;
            steps++;
          }
          ans.push_back(n - 4);
          ans.push_back(n - 4);
          ans.push_back(n - 3);
          ans.push_back(n - 3);
          rotate(a, n - 4);
          rotate(a, n - 4);
          rotate(a, n - 3);
          rotate(a, n - 3);
          for (int _ = 0; _ < (steps); ++_) {
            ans.push_back(duplicate - 1);
            ans.push_back(duplicate - 1);
            rotate(a, duplicate - 1);
            rotate(a, duplicate - 1);
            duplicate--;
          }
        }
      } else {
        ans.push_back(at - 1);
        ans.push_back(at - 1);
        rotate(a, at - 1);
        rotate(a, at - 1);
      }
    }
    insertAt++;
  }
  cout << (int)(ans).size() << endl;
  for (auto& elem : ans) cout << elem + 1 << " ";
  cout << endl;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
