t=int(input())
arr=[1]*(1000)
for i in range(2,1000):
    for j in range(i,1000,i):
        arr[j]+=i
for x in range(t):
    c=int(input())
    if c==1:
        print(1)
    ans=-1
    for i in range(len(arr)):
        if arr[i]==c:
            ans=i
    print(ans)