#include <bits/stdc++.h>
using namespace std;
long long sum[400006] = {0};
long long Min[400006] = {0};
long long Max[400006] = {0};
void solve() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  for (long long i = 0; i <= 2 * k + 3; i++) Min[i] = Max[i] = sum[i] = 0;
  for (long long i = 0; i < n / 2; i++) {
    Max[max(v[i], v[n - i - 1])]++;
    Min[min(v[i], v[n - i - 1])]++;
    sum[v[i] + v[n - i - 1]]++;
  }
  for (long long i = 1; i <= k; i++) {
    Min[i] += Min[i - 1];
    Max[i] += Max[i - 1];
  }
  long long ans = 2000000000000000005;
  long long c;
  for (long long i = 2; i <= k + 1; i++) {
    c = Min[i - 1];
    if (c <= n / 2) ans = min(ans, c + 2 * ((n / 2) - c) - sum[i]);
  }
  for (long long i = k + 1; i <= 2 * k; i++) {
    if (i - k - 1 >= 0) c = Max[i - k - 1];
    if (c <= n / 2) ans = min(ans, c * 2 + (n / 2 - c) - sum[i]);
  }
  cout << ans << "\n";
}
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
