import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline import math def sieve(n): ass = [] is_prime = [True]*(n+1) is_prime[0] = False is_prime[1] = False for i in range(2, int(math.sqrt(n))+1): if not is_prime[i]: continue for j in range(i*2, n+1, i): is_prime[j] = False for i in range(n+1): if is_prime[i]: ass.append(i) return(ass) P = sieve(35) t = int(input()) for _ in range(t): x = int(input()) ans = -1 cnt1 = [0]*len(P) y = x for j, p in enumerate(P): while y%p == 0: cnt1[j] += 1 y //= p c1 = 1 for c in cnt1: c1 *= (c+1) for i in range(2, 32): cnt2 = [0]*len(P) z = i for j, p in enumerate(P): while z%p == 0: cnt2[j] += 1 z //= p c2 = 1 for j, c in enumerate(cnt2): c2 *= (cnt1[j]+c+1) if c2%c1 == 0 and c2//c1 == 2: ans = i*x break print(ans)