rn=lambda:int(input())
rns=lambda:map(int,input().split())
rl=lambda:list(map(int,input().split()))
rs=lambda:input()
YN=lambda x:print('YES') if x else print('NO')
mod=10**9+7
m=10**7+1

sieve=m*[1]
ans=m*[-1]
for i in range(1,m):
    for j in range(i,m,i):
        sieve[j]+=1
    if ans[sieve[i]]==-1:
        ans[sieve[i]]=i

for _ in range(rn()):
    c=rn()
    print(ans[c])