import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) def main(): N = int(input()) P = list(map(lambda x: int(x) - 1, input().split())) pos = [0] * N for i, p in enumerate(P): pos[p] = i ans = [] def swap(x, y): if x > y: x, y = y, x P[x], P[y] = P[y], P[x] pos[P[x]] = x pos[P[y]] = y ans.append(x + 1) def F(L, R): if L == R: return True for x in range(L, R)[::-1]: if pos[x] < L or pos[x] >= R: return False while pos[x] < x: i = pos[x] swap(i, i+1) return True L = 0 for R in range(N): if P[R] == R: if not F(L, R): print(-1) return L = R + 1 if not F(L, N): print(-1) return print(len(ans)) print(*ans) return T = int(input()) for _ in range(T): main()