#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a;
      res %= mod;
    }
    a = a * a;
    a %= mod;
    b >>= 1;
  }
  return res % mod;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<long long> res(2 * k + 2, 0), l(2 * k + 2, 0), r(2 * k + 2, 0);
  for (long long i = 0; i < n / 2; i++) {
    res[v[i] + v[n - i - 1]]++;
    l[v[i] + v[n - i - 1] - min(v[i], v[n - i - 1]) + k]++;
    r[v[i] + v[n - i - 1] - max(v[i], v[n - i - 1]) + 1]++;
  }
  for (long long i = 2; i <= 2 * k; i++) {
    l[i] += l[i - 1];
  }
  for (long long i = 2 * k - 1; i >= 2; i--) {
    r[i] += r[i + 1];
  }
  long long ans = LLONG_MAX;
  for (long long i = 2; i <= 2 * k; i++) {
    long long p = l[i - 1] + r[i + 1] + n / 2 - res[i];
    ans = min(ans, p);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
