#include <bits/stdc++.h>
const int maxn = 2e5 + 10;
int vis[maxn << 1];
int maxx[maxn], minn[maxn];
int a[maxn];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    std::vector<int> vec;
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
    }
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n / 2; i++) {
      int tmp = a[i] + a[n - i + 1];
      if (a[i] >= a[n - i + 1]) {
        maxx[i] = a[i] + k;
        minn[i] = a[n - i + 1] + 1;
      } else
        maxx[i] = a[n - i + 1] + k, minn[i] = a[i] + 1;
      if (!vis[tmp]) vec.push_back(tmp);
      vis[tmp]++;
    }
    std::sort(a + 1, a + 1 + n);
    std::sort(vec.begin(), vec.end());
    std::sort(maxx + 1, maxx + n / 2 + 1);
    std::sort(minn + 1, minn + n / 2 + 1);
    int ans = n;
    for (int i = vec.size() - 1; i >= 0; i--) {
      int tmp = vec[i];
      int sum = n / 2;
      int pos1 = std::lower_bound(maxx + 1, maxx + n / 2 + 1, tmp) - maxx;
      int pos2 = std::upper_bound(minn + 1, minn + n / 2 + 1, tmp) - minn;
      sum -= vis[vec[i]];
      pos1--;
      pos2--;
      pos2 = n / 2 - pos2;
      sum += pos1 + pos2;
      ans = std::min(sum, ans);
    }
    if (ans > n / 2) ans = n / 2;
    printf("%d\n", ans);
  }
}
