mydict = {}

for i in range(55*10**4, 0, -1):
    result = 0
    j = 1
    while True:
        if i % j == 0:
            result += j
            if j * j != i:
                result += i // j

        j += 1

        if j * j > i :
            break

    mydict[result] = i

t = int(input())
for test_case in range(t):
    c = int(input())

    res = -1

    if c in mydict:
        res = mydict[c]




    print()
    print(res)
    print()