import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) def hurui(n): """線形篩 pl: 素数のリスト mpf: iを割り切る最小の素因数 """ pl = [] mpf = [None]*(n+1) for d in range(2,n+1): if mpf[d] is None: mpf[d] = d pl.append(d) for p in pl: if p*d>n or p>mpf[d]: break mpf[p*d] = p return pl, mpf from collections import defaultdict def factor(num): d = defaultdict(int) if num==1: d.update({1:1}) return d while num>1: d[mpf[num]] += 1 num //= mpf[num] return d def fs(num): f = factor(num) ans = [1] for k,v in f.items(): tmp = [] for i in range(len(ans)): val = 1 for _ in range(v): val *= k ans.append(ans[i]*val) return ans def sub(x,p): res = 0 while x%p==0: x //= p res += 1 return res pl, mpf = hurui(10**6) t = int(input()) ans = [] for i in range(t): x = int(input()) for p in pl: if x%p!=0: res = p break else: assert 0 m = 40 count = [-1]*m # 回数がiの素数の最小 for i in range(m)[::-1]: v = sub(x,pl[i]) count[v] = pl[i] # print(x,count) for i in range(1,m): if count[i]==-1: continue res = min(res, pow(count[i], i+1)) r = 1 for l in range(1, m): if r=0: r += 1 if r>=2*l: val = 1 for i in range(l, 2*l+1): assert count[i]>0 val *= count[i] res = min(res, val) ans.append(res*x) write("\n".join(map(str, ans)))