#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int a[N];
vector<int> command;
void operate(int i) {
  assert(i >= 0);
  int a0 = a[i + 2];
  a[i + 2] = a[i + 1], a[i + 1] = a[i], a[i] = a0;
  command.push_back(i + 1);
}
int n;
void move_f_t(int f, int t) {
  if (f == t) return;
  assert(t <= f);
  if (f - t == 1) {
    operate(t);
    move_f_t(f + 1, t);
    return;
  }
  operate(f - 2);
  move_f_t(f - 2, t);
}
int find_ind(int v, int i) {
  for (; i < N; ++i) {
    if (a[i] == v) return i;
  }
  assert(0);
}
bool vis[N];
int st[N];
void solve2() {
  command.clear();
  for (int i = 1; i < N; ++i) vis[i] = false;
  scanf("%d ", &n);
  int val = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    st[i] = a[i];
    if (vis[a[i]]) {
      val = a[i];
    }
    vis[a[i]] = true;
  }
  sort(st, st + n);
  int tind;
  if (val != -1) {
    for (int i = 0; i < n; ++i) {
      if (st[i] == val) {
        for (int j = i + 2; j < n; ++j) {
          st[j - 2] = st[j];
        }
        st[n - 2] = st[n - 1] = val;
        tind = i;
        break;
      }
    }
  }
  for (int i = 0; i < n - 2; ++i) {
    int ind = find_ind(st[i], i);
    move_f_t(ind, i);
  }
  if (val == -1) {
    for (int i = 0; i < 3; ++i) {
      bool ig = true;
      for (int j = n - 3; j < n; ++j) {
        if (st[j] != a[j]) ig = false;
      }
      if (ig) break;
      operate(n - 3);
    }
  } else {
    int ind = tind;
    if (ind % 2 == (n - 2) % 2) {
      move_f_t(n - 2, ind);
      assert(a[n - 1] == val);
      move_f_t(n - 1, ind + 1);
    } else {
      move_f_t(n - 1, ind);
      assert(a[n - 1] == val);
      move_f_t(n - 1, ind);
    }
  }
  sort(st, st + n);
  for (int i = 0; i < n; ++i) {
    if (a[i] != st[i]) {
      printf("-1\n");
      return;
    }
  }
  printf("%d\n", (int)command.size());
  for (int com : command) printf("%d ", com);
  putchar('\n');
}
void solve() {
  int t;
  cin >> t;
  while (t--) solve2();
}
inline bool exists_test0(const std::string& name);
inline bool exists_test1(const std::string& name);
int main() {
  solve();
  return 0;
}
inline bool exists_test0(const std::string& name) {
  ifstream f(name.c_str());
  return f.good();
}
inline bool exists_test1(const std::string& name) {
  if (FILE* file = fopen(name.c_str(), "r")) {
    fclose(file);
    return true;
  } else {
    return false;
  }
}
