#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> arr, z;
void rotate(int i) {
  z.push_back(i + 1);
  int x = arr[i + 2];
  arr[i + 2] = arr[i + 1];
  arr[i + 1] = arr[i];
  arr[i] = x;
}
void solve() {
  cin >> n;
  arr.resize(n);
  for (auto &x : arr) cin >> x;
  z.clear();
  for (int i = 0; i < n - 2; ++i) {
    int k = i;
    for (int j = i + 1; j < n; ++j)
      if (arr[j] < arr[k]) k = j;
    for (; k - 2 >= i; k -= 2) rotate(k - 2);
    if (k > i) {
      rotate(i);
      rotate(i);
    }
  }
  for (int i = n - 2; arr[i] > arr[i + 1]; rotate(--i))
    if (i == 0) {
      cout << -1 << "\n";
      return;
    }
  cout << z.size() << "\n";
  for (auto x : z) cout << x << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
