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=n; for(int x:p) if(n%x!=0) {sm=Math.min(sm,x); break;} else if(n%(1l*x*x)!=0) sm=Math.min(sm,1l*x*x); sm*=n; sb.append(sm+"\n"); } System.out.print(sb); } }