def cmb(n, r, mod): if ( r<0 or r>n ): return 0 return (g1[n] * g2[r] % mod) * g2[n-r] % mod mod = 998244353 N = 2*10**5 g1 = [1]*(N+1) g2 = [1]*(N+1) inverse = [1]*(N+1) for i in range( 2, N + 1 ): g1[i]=( ( g1[i-1] * i ) % mod ) inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod ) g2[i]=( (g2[i-1] * inverse[i]) % mod ) inverse[0]=0 import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import e, log,gcd input = lambda :sys.stdin.readline() mi = lambda :map(int,input().split()) li = lambda :list(mi()) for _ in range(int(input())): N = int(input()) P = li() res = [] flag = True for i in range(N): pos = P.index(i+1) for j in range(i,pos): if P[j]==j+1: flag = False break if not flag: break while pos!=i: s = -1 for j in range(i,pos)[::-1]: if P[j]!=j+2: s = j break if s==-1: for j in range(i,pos)[::-1]: res.append(j+1) P[j],P[j+1] = P[j+1],P[j] #print(P) pos = i else: for j in range(s,pos): res.append(j+1) P[j],P[j+1] = P[j+1],P[j] #print(P) res.append(pos) P[pos-1],P[pos] = P[pos],P[pos-1] #print(P) pos = pos-1 #print(P) if flag: print(len(res)) print(*res) else: print(-1)