def sumup(n):
    res=0
    for i in range(1,n+1):
        if n%i==0:
            res+=i
    return res

t=int(input())
for _ in range(t):
    c=int(input())
    j=1
    while True:
        v=sumup(j)
        if c==v:
            print(j)
            break
        elif v>c:
            print(-1)
            break
        j+=1
        
        
        
    