#include <bits/stdc++.h>
using namespace std;
const long long Inf = 1e18, Ninf = -1e18, Mod = 1e9 + 7;
const long double Eps = 1e-6;
const string Alph_lower("abcdefghijklmnopqrstuvwxyz"),
    Alph_upper("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), Digits("0123456789");
void Max_self(long long &original_value, long long new_value) {
  original_value = max(original_value, new_value);
}
void Min_self(long long &original_value, long long new_value) {
  original_value = min(original_value, new_value);
}
void To_lowercase(string &str) {
  for (long long i = 0; i < str.length(); i++) str[i] = tolower((str[i]));
}
void To_uppercase(string &str) {
  for (long long i = 0; i < str.length(); i++) str[i] = toupper(str[i]);
}
bool Is_prime(long long num) {
  if (num == 2) return true;
  for (long long div = 2; div <= sqrt(num); div++)
    if (!(num % div)) return false;
  return true;
}
long long GCD(long long num_1, long long num_2) {
  return num_2 ? GCD(num_2, num_1 % num_2) : num_1;
}
const long long M1 = 2e5 + 5, M2 = 4e5 + 10;
long long t;
long long n, k;
vector<long long> a;
vector<pair<long long, long long>> pair_values;
vector<long long> pair_freq, diff_array;
long long answer;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n >> k;
    a.clear();
    a.resize(n + 5);
    for (long long i = 1; i <= n; i++) cin >> a[i];
    pair_values.clear();
    pair_freq.clear();
    pair_freq.resize((2 * k) + 5, 0);
    diff_array.clear();
    diff_array.resize((2 * k) + 5, 0);
    for (long long i = 1; i <= n / 2; i++) {
      long long pair_value = a[i] + a[n - i + 1];
      if (pair_freq[pair_value] == 0)
        pair_values.push_back(make_pair(0, pair_value));
      pair_freq[pair_value]++;
      diff_array[1]++;
      diff_array[pair_value - max(a[i], a[n - i + 1]) + 1]--;
      diff_array[pair_value + (k - min(a[i], a[n - i + 1])) + 1]++;
    }
    for (long long i = 0; i < pair_values.size(); i++)
      pair_values[i].first = pair_freq[pair_values[i].second];
    for (long long i = 1; i <= 2 * k; i++) diff_array[i] += diff_array[i - 1];
    answer = n / 2;
    for (long long i = 0; i < pair_values.size(); i++)
      Min_self(answer, ((n / 2) - pair_values[i].first) +
                           diff_array[pair_values[i].second]);
    cout << answer << "\n";
  }
  return 0;
}
