mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] for _ in range(int(input())): X = int(input()) mi = 10**12 for i, p in enumerate(P): XX = X d = 0 while XX % p == 0: d += 1 XX //= p mi = min(mi, p ** (d + 1)) print(X * mi) if __name__ == '__main__': main()