#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int a[N];
vector<int> ans;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    ans.clear();
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int p = 1;
    while (p <= n - 2) {
      int u = p;
      for (int i = p + 1; i <= n; i++)
        if (a[i] < a[u]) u = i;
      while (u - 2 >= p)
        swap(a[u], a[u - 2]), swap(a[u], a[u - 1]), u -= 2, ans.push_back(u);
      if (u == p + 1)
        swap(a[u - 1], a[u + 1]), swap(a[u - 1], a[u]), u--, ans.push_back(u),
            ans.push_back(u);
      p++;
    }
    p = n;
    while (p >= 3) {
      int u = p;
      for (int i = p - 1; i; i--)
        if (a[i] > a[u]) u = i;
      while (u + 2 <= p)
        swap(a[u], a[u + 2]), swap(a[u], a[u + 1]), u += 2,
            ans.push_back(u - 2), ans.push_back(u - 2);
      if (u == p - 1)
        swap(a[u + 1], a[u - 1]), swap(a[u], a[u + 1]), u++,
            ans.push_back(u - 2);
      p--;
    }
    int f = 0;
    for (int i = 1; i < n; i++)
      if (a[i] > a[i + 1]) f = 1;
    if (f)
      printf("-1\n");
    else {
      printf("%d\n", ans.size());
      for (int i : ans) printf("%d ", i);
      printf("\n");
    }
  }
  return 0;
}
