#include <bits/stdc++.h>
void make_swap(std::vector<int>& nums, int ind) {
  int first = nums[ind];
  nums[ind] = nums[ind + 2];
  nums[ind + 2] = nums[ind + 1];
  nums[ind + 1] = first;
}
void swap_two_pairs(std::vector<int>& nums, int ind, std::vector<int>& answer) {
  answer.push_back(ind + 1);
  make_swap(nums, ind + 1);
  answer.push_back(ind);
  make_swap(nums, ind);
}
void print_ans(const std::vector<int>& answer) {
  std::cout << answer.size() << "\n";
  for (auto i : answer) {
    std::cout << i + 1 << " ";
  }
  std::cout << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  int t;
  std::cin >> t;
  for (int _ = 0; _ < t; ++_) {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      std::cin >> a[i];
    }
    std::vector<int> answer;
    for (int i = 0; i < n - 3; ++i) {
      int curr_index = i;
      for (int j = i; j < n; ++j) {
        if (a[j] < a[curr_index]) {
          curr_index = j;
        }
      }
      while (curr_index != i && curr_index != i + 1) {
        answer.push_back(curr_index - 2);
        make_swap(a, curr_index - 2);
        curr_index -= 2;
      }
      if (curr_index == i + 1) {
        swap_two_pairs(a, i, answer);
      }
    }
    if (a[n - 3] <= a[n - 2] && a[n - 2] <= a[n - 1]) {
      print_ans(answer);
      continue;
    }
    if (a[n - 1] <= a[n - 3] && a[n - 3] <= a[n - 2]) {
      answer.push_back(n - 3);
      make_swap(a, n - 3);
      print_ans(answer);
      continue;
    }
    if (a[n - 2] <= a[n - 1] && a[n - 1] <= a[n - 3]) {
      answer.push_back(n - 3);
      make_swap(a, n - 3);
      answer.push_back(n - 3);
      make_swap(a, n - 3);
      print_ans(answer);
      continue;
    }
    while (a[n - 3] > a[n - 2] || a[n - 3] > a[n - 1]) {
      answer.push_back(n - 3);
      make_swap(a, n - 3);
    }
    int similar = -1;
    for (int i = 0; i < n - 3; ++i) {
      if (a[i] == a[i + 1]) {
        similar = i;
      }
    }
    if (similar == -1) {
      std::cout << -1 << "\n";
      continue;
    }
    int curr = similar;
    while (curr != n - 5 && curr != n - 4) {
      swap_two_pairs(a, curr, answer);
      curr += 2;
    }
    if (curr == n - 4) {
      swap_two_pairs(a, curr, answer);
    } else {
      swap_two_pairs(a, n - 5, answer);
      answer.push_back(n - 4);
      make_swap(a, n - 4);
      swap_two_pairs(a, n - 4, answer);
    }
    print_ans(answer);
  }
}
