def solve(x): y = x f = [0] * 40 for i in range(2, 40): while y % i == 0: f[i] += 1 y //= i for i in range(2, 40): j = i p = q = 1 for k in range(2, i+1): t = 0 while j % k == 0: t += 1 j //= k if t: p *= f[k] + 1 + t q *= f[k] + 1 if p == q * 2: print(x * i) return n = int(input()) for _ in range(n): solve(int(input()))