def main(): primes=[] for i in range(2,1000): ok=True for j in range(2,i): ok&=bool(i%j) if ok: primes.append(i) INF=float('inf') for _ in range(int(input())): x=int(input()) ans=INF for d in primes: if x%d==0: tmp1=x tmp2=1 while tmp1%d==0: tmp1//=d tmp2*=d*d ans=min(ans,tmp1*tmp2*d) else: ans=min(ans,x*d) print(ans) main()