import java.io.*; import java.math.BigInteger; 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 t=Integer.parseInt(bu.readLine()); while(t-->0) { int n=Integer.parseInt(bu.readLine()); long l=1,r=(long)1e18,mid,ans=r; while(l<=r) { mid=(l+r)>>1; if(count(mid)>=n) { ans=mid; r=mid-1; } else l=mid+1; } sb.append(ans+"\n"); } System.out.print(sb); } static long c[]=new long[61]; static long count(long n) { int i,N=60; for(i=2;i<=N;i++) { int l=2,r=(int)1e9,mid,ans=0; long v; while(l<=r) { mid=(l+r)>>1; v=power(mid,i,n); if(v<=n) { ans=mid-1; l=mid+1; } else r=mid-1; } c[i]=ans; } int j; long ans=1; for(i=N;i>1;i--) { //System.out.print(c[i]+" "); for(j=2*i;j<=N;j+=i) c[i]-=c[j]; ans+=c[i]; } //System.out.println(n+" "+ans); return ans; } static long power(long a,int b,long n) { if(a>n) return n+1; if(a>(int)1e9 && n>=2) return n+1; BigInteger res=new BigInteger("1"); while(b!=0) { res=res.multiply(res.valueOf(a)); if(res.compareTo(res.valueOf(n))>0) return n+1; b--; } return res.longValue(); } }