#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count() +
            'd' + 'o' + 'i' + 'n' + 'g' + 'g' + 'e' + 'y');
const int inf = 1e9;
const double eps = 1e-6;
double start_time;
const int maxn = 5e5 + 1;
int t0[maxn], t1[4 * maxn], t2[4 * maxn];
int a1[4 * maxn], a2[4 * maxn];
void push1(int v, int tl, int tr) {
  t1[v] += a1[v];
  if (tl == tr) {
    a1[v] = 0;
    return;
  }
  a1[2 * v + 1] += a1[v];
  a1[2 * v + 2] += a1[v];
  a1[v] = 0;
}
void push2(int v, int tl, int tr) {
  t2[v] += a2[v];
  if (tl == tr) {
    a2[v] = 0;
    return;
  }
  a2[2 * v + 1] += a2[v];
  a2[2 * v + 2] += a2[v];
  a2[v] = 0;
}
void upd1(int v, int tl, int tr, int l, int r, int x) {
  push1(v, tl, tr);
  if (l > r || max(tl, l) > min(tr, r)) return;
  if (l <= tl && tr <= r) {
    a1[v] += x;
    push1(v, tl, tr);
    return;
  }
  int m = (tl + tr) / 2;
  upd1(2 * v + 1, tl, m, l, r, x);
  upd1(2 * v + 2, m + 1, tr, l, r, x);
  t1[v] = t1[2 * v + 1] + t1[2 * v + 2];
}
void upd2(int v, int tl, int tr, int l, int r, int x) {
  push2(v, tl, tr);
  if (l > r || max(tl, l) > min(tr, r)) return;
  if (l <= tl && tr <= r) {
    a2[v] += x;
    push2(v, tl, tr);
    return;
  }
  int m = (tl + tr) / 2;
  upd2(2 * v + 1, tl, m, l, r, x);
  upd2(2 * v + 2, m + 1, tr, l, r, x);
  t2[v] = t2[2 * v + 1] + t2[2 * v + 2];
}
pair<int, int> get(int v, int tl, int tr, int i) {
  push1(v, tl, tr);
  push2(v, tl, tr);
  if (tl == tr) return {t1[v], t2[v]};
  int m = (tl + tr) / 2;
  if (i <= m) return get(2 * v + 1, tl, m, i);
  return get(2 * v + 2, m + 1, tr, i);
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int sa = 0;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int mv = 2 * k;
  for (int i = 0; i < n / 2; ++i) {
    mv = max(mv, a[i] + a[n - 1 - i]);
    mv = max(mv, a[i] + k);
    mv = max(mv, a[n - 1 - i] + k);
  }
  mv += 10;
  for (int i = 0; i < 4 * mv; ++i) t1[i] = t2[i] = a1[i] = a2[i] = 0;
  for (int i = 0; i < mv; ++i) t0[i] = 0;
  for (int i = 0; i < n / 2; ++i) {
    int s = a[i] + a[n - 1 - i];
    t0[s]++;
    int l1 = min(1 + a[n - 1 - i], 1 + a[i]),
        r1 = max(k + a[i], k + a[n - 1 - i]);
    if (s < l1 || r1 < s) {
      upd1(0, 0, mv - 1, s, s, 1);
    }
    upd1(0, 0, mv - 1, l1, r1, 1);
    int l2 = 2, r2 = 2 * k;
    if ((s < l2 || r2 < s) && (s < l1 || r1 < s)) {
      upd2(0, 0, mv - 1, s, s, 1);
    }
    if (r1 < l2 || r2 < l1) {
      upd2(0, 0, mv - 1, l1, r1, 1);
    } else {
      l2 = min(l2, l1);
      r2 = max(r2, r1);
    }
    upd2(0, 0, mv - 1, l2, r2, 1);
  }
  int ans = inf;
  for (int x = 2; x < mv; ++x) {
    int c0 = t0[x], c1, c2;
    tie(c1, c2) = get(0, 0, mv - 1, x);
    if (c2 < n / 2) continue;
    c2 -= c1;
    c1 -= c0;
    ans = min(ans, c1 + 2 * c2);
  }
  cout << ans << "\n";
}
signed main() {
  start_time = clock();
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) solve();
  return 0;
}
