t = int(input())
for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    if len(a) < 1 or len(set(a)) == len(a):
        print(-1)
    else:
        d = {}
        for j in range(n):
            if a[j] in d:
                if j - d[a[j]][1] < d[a[j]][0]:
                    d[a[j]] = [j - d[a[j]][1], j]
            else:
                d[a[j]] = [10 ** 8, j]
        ans = min(d.values())
        if ans[0] == 1:
            print(2)
        else:
            print(ans[0] + 1)
        print(d)
        