def main(): T = int(input()) for i in range(T): N = int(input()) p = [0] + list(map(int, input().split())) + [N+1] fixed_idx = [i for i in range(N+2) if i == p[i]] ok = True ans = [] def swap(i): assert i != p[i] assert i+1 != p[i+1] ans.append(i) p[i], p[i+1] = p[i+1], p[i] for i in range(len(fixed_idx)-1): f, t = fixed_idx[i], fixed_idx[i+1] if sorted(p[f+1:t]) != list(range(f+1, t)): ok = False break for i in range(f+1, t): for j in range(i, t): if p[j] == i: i_idx = j if i_idx == i: continue for j in range(i_idx, i, -1): if p[j-1] == j and j != i+1: swap(j-2) swap(j-1) if not ok: print(-1) else: assert p == sorted(p) print(len(ans)) print(*ans) if __name__ == '__main__': main()