#include <bits/stdc++.h>
using namespace std;
const int64_t M1 = 998244353;
const int64_t M2 = 1000000007;
int64_t mp[400001];
int64_t b[400001];
int64_t a[200001];
void solve() {
  int64_t n, k;
  cin >> n >> k;
  for (int64_t i = 0; i <= 2 * k; i++) mp[i] = b[i] = 0;
  for (int64_t i = 0; i < n; i++) cin >> a[i];
  for (int64_t i = 0; i < (n / 2); i++) {
    mp[a[i] + a[n - 1 - i]]++;
    b[min(a[i] + 1, a[n - 1 - i] + 1)]++;
    b[max(a[i] + k, a[n - 1 - i] + k) + 1]--;
  }
  for (int64_t i = 1; i <= 2 * k; i++) b[i] += b[i - 1];
  int64_t ans = n;
  for (int64_t i = 2; i <= 2 * k; i++) ans = min(ans, n - b[i] - mp[i]);
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int64_t t;
  cin >> t;
  while (t--) solve();
}
