def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return [i for i in range(n + 1) if is_prime[i]] pr = primes(200) t = int(input()) for _ in range(t): x = int(input()) ans = 10 ** 18 l = [(0, 100000)] for p in pr: cnt = 1 t = x while t % p == 0: t //= p cnt += 1 if l[-1][1] > cnt: res = x l.append((p, cnt)) for i in range(len(l) - 1, 0, -1): if l[i - 1][1] >= cnt * 2: res *= pow(l[i][0], cnt * 2 - l[i][1]) break else: res *= pow(l[i][0], l[i - 1][1] - l[i][1]) ans = min(ans, res) if x % p > 0: break print(ans)