def yesno(p): for idx, (_, i) in enumerate(p): if idx == i and sum(j < i for _, j in p[:idx]) != i: return False return True def swap(p, i, ops, comp): if p[i][1] == i or p[i+1][1] == i+1: return if comp(p[i]) > comp(p[i+1]): p[i], p[i+1] = p[i+1], p[i] ops.append(i+1) def sort(p, ops, comp): for _ in p: for i in range(len(p)-1): swap(p, i, ops, comp) def solve(): n = int(input()) p = [(i-1 < idx, i-1) for idx, i in enumerate(map(int, input().split()))] if not yesno(p): print(-1) return ops = [] sort(p, ops, lambda x: x) sort(p, ops, lambda x: x[1]) print(len(ops)) print(" ".join(map(str, ops))) if __name__ == "__main__": t = int(input()) for _ in range(t): solve()