from itertools import chain import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) inf = 10 ** 18 def prime_set(N): """ Nまでの素数のsetを返す """ if N < 4: return ({}, {}, {2}, {2, 3})[N] Nsq = int(N ** 0.5 + 0.5) + 1 primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6))) for i in range(5, Nsq, 2): if i in primes: primes -= set(range(i * i, N + 1, i * 2)) return sorted(primes) def F(n, p): res = 1 for _ in range(p): res *= n if res > inf: return inf return res U = 10 ** 6 Prime = prime_set(U) T = int(input()) for _ in range(T): X = int(input()) ans = X D = inf for p in Prime: if p >= D: break cnt = 0 while X % p == 0: cnt += 1 X //= p D = min(D, F(p, cnt + 1)) print(ans * D)