import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int N=500000,pr[]=new int[N+1],i,j; ArrayList p=new ArrayList<>(); for(i=2;i<=N;i++) if(pr[i]==0) { p.add(i); for(j=i;j<=N;j+=i) pr[j]=i; } int t=Integer.parseInt(bu.readLine()); while(t-->0) { long n=Long.parseLong(bu.readLine()); long sm=Long.MAX_VALUE; for(int x:p) if(n%x!=0) {sm=Math.min(sm,x); break;} else { long y=n,mul=x; while(y%x==0) {y/=x; mul*=x;} sm=Math.min(sm,mul); } sm*=n; sb.append(sm+"\n"); } System.out.print(sb); } }