#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
const int oo = 1e9 + 20;
const int MOD = 998244353;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a;
    set<int> ve;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      ve.insert(x);
      a.push_back(x);
    }
    vector<int> ans;
    for (int i = 0; i < n - 2; ++i) {
      pair<int, int> mn = {oo, -1};
      for (int j = i; j < n; ++j) mn = min(mn, {a[j], j});
      while (mn.second > i) {
        if (mn.second - 2 >= i) {
          swap(a[mn.second], a[mn.second - 2]);
          swap(a[mn.second], a[mn.second - 1]);
          ans.push_back(mn.second - 1);
          mn.second -= 2;
        } else {
          swap(a[mn.second], a[mn.second - 1]);
          swap(a[mn.second], a[mn.second + 1]);
          ans.push_back(mn.second);
          ans.push_back(mn.second);
          mn.second -= 1;
        }
      }
    }
    int ok = (a[n - 2] > a[n - 1] && ve.size() == n);
    if (ok) {
      cout << -1 << '\n';
    } else {
      if (a[n - 2] > a[n - 1]) {
        int cur = n - 2;
        while (a[cur - 1] != a[cur + 1]) {
          ans.push_back(cur);
          swap(a[cur + 1], a[cur - 1]);
          swap(a[cur], a[cur + 1]);
          cur--;
        }
        ans.push_back(cur);
      }
      ok = (ans.size() <= n * n);
      if (ok) {
        cout << ans.size() << '\n';
        for (auto i : ans) cout << i << ' ';
        cout << '\n';
      } else
        cout << -1 << '\n';
    }
  }
}
