#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
void move(vector<int> &a, int pos) {
  ans.push_back(pos);
  swap(a[pos], a[pos + 1]);
  swap(a[pos], a[pos + 2]);
}
void rmove(vector<int> &a, int pos) {
  move(a, pos - 1);
  move(a, pos - 1);
}
void move(vector<int> &a, int &pos, int tar) {
  if (pos == tar) return;
  if (pos == tar + 1) {
    move(a, tar);
    move(a, tar);
    pos = tar;
    return;
  }
  move(a, pos - 2);
  pos = pos - 2;
  return move(a, pos, tar);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a;
  ans.clear();
  a.resize(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int j = 1; j < n - 1; j++) {
    int mn = 1e9, mnpos = 0;
    for (int i = j; i <= n; i++)
      if (mn > a[i]) {
        mn = a[i];
        mnpos = i;
      }
    if (mnpos == n) {
      move(a, mnpos - 2);
      mnpos = n - 2;
    }
    move(a, mnpos, j);
  }
  if (a[n - 1] > a[n]) {
    bool flag1 = 0;
    bool flag2 = 0;
    int pos;
    for (int i = 1; i < n; i++)
      if (a[i] == a[i + 1]) {
        flag1 = 1, pos = i;
        break;
      }
    if (a[n] == a[n - 2]) flag2 = 1;
    if (flag1) {
      int tarpos = n - 1;
      while (tarpos > pos + 1) {
        rmove(a, tarpos);
        tarpos--;
      }
      move(a, pos);
      move(a, pos + 1);
      move(a, pos);
      move(a, pos);
      tarpos++;
      while (tarpos < n - 1) {
        move(a, tarpos);
        tarpos++;
      }
    } else if (flag2) {
      move(a, n - 2);
    } else {
      cout << -1 << '\n';
      return;
    }
  }
  cout << ans.size() << '\n';
  for (auto c : ans) cout << c << " ";
  cout << '\n';
}
int32_t main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
