T = int(input()) import sys sys.setrecursionlimit(10 ** 8) def calc(p,ans): N = len(p) if N == 1:return True while True: for i in range(N): if p[i] == N: index = i break if index == N-1: return calc(p[:-1],ans) r = index + 1 while r < N: if p[r] == r + 1: return False if p[r] == r: r += 1 else: break if r == N: if p[index+1] == index+1: r -= 1 else: return False for k in range(r-1,index-1,-1): ans.append(k+1) p[k],p[k+1] = p[k+1],p[k] for _ in range(T): N = int(input()) p = list(map(int,input().split())) ans = [] if calc(p,ans): print(len(ans)) print(*ans) else: print(-1)