#include <bits/stdc++.h>
using namespace std;
int a[505];
int sorted_a[505];
void rot(int i) {
  i--;
  int temp = a[i + 2];
  a[i + 2] = a[i + 1];
  a[i + 1] = a[i];
  a[i] = temp;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int cases;
  cin >> cases;
  while (cases--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sorted_a[i] = a[i];
    }
    sort(sorted_a, sorted_a + n);
    vector<int> ans;
    for (int i = n - 1; i > 1; i--) {
      int j = i;
      while (a[j] != sorted_a[i]) j--;
      if (j == 0) {
        ans.push_back(1);
        rot(1);
        j++;
      }
      for (; j < i; j++) {
        ans.push_back(j);
        rot(j);
      }
    }
    if (a[0] != sorted_a[0]) {
      if (a[0] == a[2]) {
        ans.push_back(1);
        ans.push_back(1);
        rot(1);
        rot(1);
      } else {
        for (int i = 2; i < n - 1; i++) {
          if (a[i] == a[i + 1]) {
            for (int j = i; j >= 1; j--) {
              ans.push_back(j);
              rot(j);
            }
            break;
          }
        }
      }
    }
    if (a[0] == sorted_a[0]) {
      cout << ans.size() << "\n";
      for (int i : ans) cout << i << " ";
      cout << "\n";
    } else
      cout << "-1\n";
  }
  return 0;
}
