#include <bits/stdc++.h>   using namespace std;   vector<int> v, ans;   void op(int i) {     int x = v[i + 2];     v[i + 2] = v[i + 1];     v[i + 1] = v[i];     v[i] = x;     if (ans.size() >= 2 && ans[ans.size() - 1] == i + 1 &&         ans[ans.size() - 2] == i + 1)       ans.pop_back(), ans.pop_back();     else       ans.push_back(i + 1);   }   void reach(int x, int y) {     while (y > x + 1) op(y - 2), y -= 2;     if (y == x + 1) op(y - 1), op(y - 1);   }   int main(int argc, char **argv) {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, st = 0, temp = 0;       ans.clear();       cin >> n;       v.resize(n);       vector<int> ar(501, -1);       int val = -1, x, y;       for (int i = 0; i < n; i++) {         cin >> v[i];         if (ar[v[i]] != -1) val = v[i], x = ar[v[i]], y = i;         ar[v[i]] = i;       }       if (val != -1) v[x] = v[y] = 2000;       while (n - st > 3) {         int mi = 1000, in;         for (int j = st; j < n; j++)           if (v[j] < mi) mi = v[j], in = j;         reach(st, in);         st++;       }       if (val == -1) {         while (!(v[st] <= v[st + 1] && v[st + 1] <= v[st + 2])) {           op(st), temp++;           if (temp > 5) {             cout << -1 << endl;             goto brk;           }         }       } else {         while (v[st + 1] != 2000 || v[st + 2] != 2000) op(st);         while (st >= 0 && val < v[st]) op(st), op(st), st--;       }       cout << ans.size() << endl;       for (auto x : ans) cout << x <<    ;       cout << endl;     brk:;     }   }   