#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    int save;
    vector<int> ans;
    for (int i = 0; i < n - 2; i++) {
      int mi = 5555;
      save = 0;
      for (int j = i; j < n; j++) {
        if (mi > a[j]) {
          mi = a[j];
          save = j;
        }
      }
      while (save >= i + 2) {
        ans.push_back(save - 2 + 1);
        swap(a[save], a[save - 1]);
        swap(a[save - 1], a[save - 2]);
        save -= 2;
      }
      if (save != i) {
        ans.push_back(save - 1 + 1);
        ans.push_back(save - 1 + 1);
        swap(a[i], a[i + 1]);
        swap(a[i + 1], a[i + 2]);
      }
    }
    if (a[n - 2] > a[n - 1]) {
      if (a[n - 1] == a[n - 3]) {
        ans.push_back(n - 3 + 1);
        cout << ans.size() << "\n";
        for (long long i = 0; i < (long long)ans.size(); i++)
          cout << ans[i] << " ";
        cout << "\n";
        continue;
      } else {
        int fg = 0;
        for (int i = 0; i < n - 1; i++) {
          if (a[i] == a[i + 1]) {
            for (int j = n - 3; j >= i; j--) {
              ans.push_back(j + 1);
            }
            fg = 1;
            break;
          }
          if (fg == 1) break;
        }
        if (fg == 0) {
          cout << -1 << "\n";
          continue;
        } else {
          cout << ans.size() << "\n";
          for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] << " ";
          cout << "\n";
          continue;
        }
      }
    } else {
      cout << ans.size() << "\n";
      for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] << " ";
      cout << "\n";
      continue;
    }
  }
  return 0;
}
