#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int va[N];
vector<int> v;
inline void update(int i, int j) {
  if (i - j > 1) {
    int tep = va[i];
    va[i] = va[i - 1];
    va[i - 1] = va[i - 2];
    va[i - 2] = tep;
    v.push_back(i - 2);
    i -= 2;
    if (i != j) update(i, j);
  } else {
    v.push_back(j);
    v.push_back(j);
    int vj = va[j], vi = va[i];
    va[i] = va[i + 1];
    va[j] = vi;
    va[i + 1] = vj;
  }
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    v.clear();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> va[i];
    bool ff = 0;
    for (int i = 1; i <= n - 2; i++) {
      int pos = i;
      for (int j = i; j <= n; j++)
        if (va[pos] > va[j]) pos = j;
      if (i != pos) update(pos, i);
    }
    for (int i = n - 2; i >= 1; i--) {
      int fi = 1;
      for (int j = 1; j < n; j++)
        if (va[j] > va[j + 1]) {
          fi = 0;
          break;
        }
      if (fi) {
        ff = 1;
        break;
      }
      v.push_back(i);
      int tmp = va[i + 2];
      va[i + 2] = va[i + 1];
      va[i + 1] = va[i];
      va[i] = tmp;
    }
    int fi = 1;
    for (int j = 1; j < n; j++)
      if (va[j] > va[j + 1]) {
        fi = 0;
        break;
      }
    if (fi) ff = 1;
    if (!ff)
      cout << "-1" << endl;
    else {
      cout << v.size() << endl;
      for (int i = 0; i < v.size(); i++) {
        if (i != 0) cout << " ";
        cout << v[i];
      }
      cout << endl;
    }
  }
}
