import sys
maxi=10**6+1
maxi2=10**7+1
temp=[0 for i in range(maxi)]
ans=[-1 for i in range(maxi2)]
for i in range(1,maxi):
    for j in range(i,maxi,i):
        temp[j]+=i
for i in range(maxi):
    if temp[i]<10**7+1:
        ans[temp[i]]=i
input = sys.stdin.readline
for _ in range(int(input())):
    n=int(input())
    print(ans[n])