#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1000005;
const int INF = 1000000000;
const int MOD = 998244353;
void fix(int &x) {
  if (x >= MOD) {
    x -= MOD;
  }
}
int a[Nmax];
pair<int, int> sums[Nmax];
int main() {
  int t, n, k;
  cin.sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i <= n / 2; i++) {
      sums[i].first = a[i] + a[n - i + 1];
      sums[i].second = a[i];
    }
    n >>= 1;
    sort(sums + 1, sums + n + 1);
    vector<int> marked(2 * k + 1, 0);
    vector<int> ans(2 * k + 1, 0);
    int cnt = 0, nr_smaller = 0, p = 1;
    for (int i = 1; i <= 2 * k; i++) {
      while (p <= n && sums[p].first < i) {
        nr_smaller++;
        int x = sums[p].first - sums[p].second;
        marked[sums[p].first + max(k - sums[p].second, k - x)]++;
        p++;
      }
      ans[i] += cnt + nr_smaller;
      cnt += marked[i];
    }
    cnt = 0;
    p = n;
    int nr_greater = 0, sol = INF;
    vector<int> marked2(2 * k + 1, 0);
    for (int i = 2 * k; i; i--) {
      while (p > 0 && sums[p].first > i) {
        nr_greater++;
        int x = sums[p].first - sums[p].second;
        marked2[sums[p].first - max(sums[p].second - 1, x - 1)]++;
        p--;
      }
      ans[i] += cnt + nr_greater;
      sol = min(sol, ans[i]);
      cnt += marked2[i];
    }
    cout << sol << "\n";
  }
  return 0;
}
