#include <bits/stdc++.h>
using namespace std;
int ans[255000], a[510], tot;
void move(int u) {
  int t1, t2, t3;
  t1 = a[u], t2 = a[u + 1], t3 = a[u + 2];
  a[u] = t3, a[u + 1] = t1, a[u + 2] = t2;
}
int t, n, mn, mx, u;
int main() {
  scanf("%d", &t);
  while (t--) {
    tot = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n - 2; i++) {
      mn = 1000;
      for (int j = i; j <= n; j++)
        if (a[j] < mn) mn = a[j], u = j;
      while (u >= i + 2) ans[++tot] = u - 2, move(u - 2), u -= 2;
      if (u == i + 1) move(i), move(i), ans[++tot] = i, ans[++tot] = i;
    }
    for (int i = n; i >= 3; i--) {
      mx = -1;
      for (int j = i; j >= 1; j--)
        if (a[j] > mx) mx = a[j], u = j;
      while (u <= i - 2) ans[++tot] = u, move(u), u += 2;
      if (u == i - 1) move(i - 2), ans[++tot] = i - 2;
    }
    for (int i = 1; i < n; i++)
      if (a[i] > a[i + 1]) tot = -1;
    if (tot == -1)
      printf("-1\n");
    else {
      printf("%d\n", tot);
      for (int i = 1; i <= tot; i++) printf("%d ", ans[i]);
      printf("\n");
    }
  }
  return 0;
}
