#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
void tros(int i, vector<int> &v) {
  int t = v[i + 2];
  v[i + 2] = v[i + 1];
  v[i + 1] = v[i];
  v[i] = t;
}
void sort(vector<int> &v) {
  int n = v.size();
  for (int i = 0; i < n - 2; i++) {
    int mn = 600, id = -1;
    for (int j = i; j < n; j++) {
      if (mn <= v[j]) continue;
      id = j;
      mn = v[j];
    }
    while (id >= i + 2) {
      ans.push_back(id - 2);
      tros(id - 2, v);
      id -= 2;
    }
    if (id == i + 1) {
      ans.push_back(id - 1);
      ans.push_back(id - 1);
      tros(id - 1, v);
      tros(id - 1, v);
    }
  }
}
bool sorted(vector<int> &v) {
  for (int i = 1; i < v.size(); i++)
    if (v[i] < v[i - 1]) return 0;
  return 1;
}
void fix(vector<int> &v) {
  int dup = -1, n = v.size();
  for (int i = n - 1; i > 0; i--) {
    if (v[i] == v[i - 1]) {
      dup = i - 1;
      break;
    }
  }
  if (~dup) {
    int id = n - 1;
    while (id >= dup + 2) {
      ans.push_back(id - 2);
      tros(id - 2, v);
      id -= 2;
    }
    ans.push_back(dup);
    tros(dup, v);
  }
}
void fix2(vector<int> &v) {
  int dup = -1, n = v.size();
  for (int i = n - 1; i > 0; i--) {
    if (v[i] == v[i - 1]) {
      dup = i - 1;
      break;
    }
  }
  if (~dup) {
    int id = n - 1;
    while (id >= dup + 2) {
      ans.push_back(id - 2);
      tros(id - 2, v);
      id -= 2;
    }
    ans.push_back(dup);
    tros(dup, v);
    ans.push_back(dup);
    tros(dup, v);
  }
}
void fix3(vector<int> &v) {
  int dup = -1, n = v.size();
  for (int i = n - 1; i > 0; i--) {
    if (v[i] == v[i - 1]) {
      dup = i - 1;
      break;
    }
  }
  if (~dup) {
    int id = n - 1;
    while (id >= dup + 2) {
      ans.push_back(id - 2);
      tros(id - 2, v);
      id -= 2;
    }
    ans.push_back(dup);
    tros(dup, v);
    ans.push_back(dup);
    tros(dup, v);
    ans.push_back(dup);
    tros(dup, v);
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, mx = 0, id = -1;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      if (v[i] > mx) mx = v[i], id = i;
    }
    sort(v);
    if (!sorted(v)) fix(v), sort(v);
    if (v[n - 1] == v[n - 3] and v[n - 2] > v[n - 1]) {
      ans.push_back(n - 3);
      tros(n - 3, v);
    }
    if (sorted(v)) {
      cout << ans.size() << endl;
      assert(ans.size() <= n * n);
      for (int i : ans) cout << i + 1 << ' ';
      cout << endl;
    } else
      cout << -1 << endl;
    ans.clear();
  }
}
