#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n), temp, move;
  for (int i = 0; i < n; ++i) cin >> v[i];
  temp = v;
  sort(temp.begin(), temp.end());
  for (int i = 0; i < n - 2; ++i) {
    int ind;
    for (int j = i; j < n; ++j) {
      if (v[j] == temp[i]) {
        ind = j;
        break;
      }
    }
    if (ind == i) continue;
    ind -= 2;
    while (ind >= i) {
      int a = v[ind], b = v[ind + 1], c = v[ind + 2];
      v[ind] = c;
      v[ind + 1] = a;
      v[ind + 2] = b;
      move.push_back(ind);
      ind -= 2;
    }
    ind += 2;
    if (ind != i) {
      --ind;
      int a = v[ind], b = v[ind + 1], c = v[ind + 2];
      v[ind] = c;
      v[ind + 1] = a;
      v[ind + 2] = b;
      a = v[ind];
      b = v[ind + 1];
      c = v[ind + 2];
      v[ind] = c;
      v[ind + 1] = a;
      v[ind + 2] = b;
      move.push_back(ind);
      move.push_back(ind);
    }
  }
  if (v[n - 2] > v[n - 1]) {
    if (v[n - 1] == v[n - 3])
      move.push_back(n - 3);
    else {
      int ind = -1;
      for (int i = n - 4; i >= 0; --i) {
        if (v[i] == v[i + 1]) {
          ind = i;
          break;
        }
      }
      if (ind == -1) {
        cout << -1 << "\n";
        return;
      }
      for (int i = ind; i <= n - 5; ++i) {
        move.push_back(i);
      }
      move.push_back(n - 3);
      move.push_back(n - 4);
      for (int i = n - 5; i >= ind; --i) {
        move.push_back(i);
        move.push_back(i);
      }
    }
    cout << move.size() << "\n";
    for (auto i : move) cout << i + 1 << " ";
    cout << "\n";
  } else {
    cout << move.size() << "\n";
    for (auto i : move) cout << i + 1 << " ";
    cout << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
