inlineintread(){ int x = 0, f = 0; char c = 0; while (!isdigit(c)) f |= c == '-', c = getchar(); while (isdigit(c)) x = (x << 3) + (x << 1) + (c & 15), c = getchar(); return f ? -x : x; }
#define N 2040
int n, a[N]; vector<int> res;
intcan(int n){ for (int i = 1; i <= n; i ++) { if ((i & 1) != (a[i] & 1)) returnfalse; } returntrue; }
intcheck(int x){ for (int i = 1; i <= x; i ++) { if (i != a[i]) returnfalse; } returntrue; }
voidF(int x){ res.emplace_back(x); reverse(a + 1, a + x + 1); }
signedmain(){ for (int T = read(); T --;) { res.clear(); n = read(); for (int i = 1; i <= n; i ++) a[i] = read(); if (!can(n)) { puts("-1"); continue; } while (!check(n)) { int x, y; for (int i = 1; i <= n; i ++) { if (a[i] == n) x = i; if (a[i] == n - 1) y = i; } if (x == n && y == n - 1) { n -= 2; continue; } if (x + 1 < y) F(x), F(y - 1), x = y - 1; if (y + 1 < x) F(x), y = (x + 1 - y), F(y - 1), x = y - 1; if (x + 1 == y) F(y + 1), x = (y + 2 - x), F(x); elseF(x); F(n), n -= 2; } printf("%d\n", res.size()); for (auto x : res) printf("%d ", x); if (res.size()) puts(""); } return0; }