arr = [1 for i in range(1200)]
length = len(arr)
for i in range(2,length):
    for j in range(i,length,i):
        arr[j]+=i
for x in range(int(input())):
    c=int(input())
    if c==1:
        print(1)
        continue
    ans=-1
    for i in range(length):
        if arr[i]==c:
            ans=i
            break
    print(ans)