T = int(input()) C = 10 ** 6 dat = [0] * C prime = [] for i in range(2,C): if dat[i] == 0: prime.append(i) for j in range(2 * i,C,i): dat[j] = 1 for _ in range(T): X = int(input()) u = X P = -1 ans = 1 << 30 for p in prime: if X % p != 0: P = p break else: count = 0 while X % p == 0: count += 1 X //= p if pow(p,count + 1) < ans: ans = p ** (count+1) if ans < P: print(ans * u) else: print(u * P)