#include <bits/stdc++.h>
using namespace std;
using ill = long long;
class solution {
 public:
  void solve() {
    int tct;
    cin >> tct;
    for (int tcc = 1; tcc <= tct; ++tcc) {
      int n;
      cin >> n;
      vector<int> a(n, 0);
      vector<pair<int, int>> res(n);
      for (int i = 0; i <= n - 1; ++i) {
        cin >> a[i];
        res[i] = {a[i], i};
      }
      sort(res.begin(), res.end());
      for (int i = 0; i <= n - 1; ++i) a[res[i].second] = i;
      int cntR = 0;
      for (int i = 0; i <= n - 1; ++i)
        for (int j = i + 1; j <= n - 1; ++j) cntR += a[j] < a[i];
      if (cntR % 2 == 1) {
        for (int i = 0; i <= n - 1; ++i) {
          if (res[i].first == res[i + 1].first) {
            swap(a[res[i].second], a[res[i + 1].second]);
            break;
          }
        }
      }
      auto op = [&](int pos) {
        swap(a[pos + 1], a[pos + 2]);
        swap(a[pos], a[pos + 1]);
      };
      vector<int> ansO;
      for (int i = 0; i <= n - 3; ++i) {
        int pos = min_element(a.begin() + i, a.end()) - a.begin();
        while (pos > i + 1) {
          op(pos - 2);
          ansO.push_back(pos - 2);
          pos -= 2;
        }
        if (pos != i) {
          op(i);
          op(i);
          ansO.push_back(i);
          ansO.push_back(i);
          pos = i;
        }
      }
      for (int i = 0; i <= 2; ++i) {
        if (is_sorted(a.begin(), a.end())) break;
        op(n - 3);
        ansO.push_back(n - 3);
      }
      if (is_sorted(a.begin(), a.end()) == false) {
        cout << "-1\n";
      } else {
        cout << ansO.size() << '\n';
        bool first = true;
        for (auto x : ansO) {
          if (first)
            first = false;
          else
            cout << ' ';
          cout << x + 1;
        }
        cout << '\n';
      }
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  solution sln1;
  sln1.solve();
  cout.flush();
  return 0;
}
