import sys input=sys.stdin.readline #文字列入力はするな!! from math import log def f(x): if x==0:return 0 g=[0]*62 res=1 for b in range(2,62): a=int(x**(1/b)) while (a+1)**b<=x: a+=1 while a**b>x:a-=1 if a>=2:g[b]=a-1 for b in range(61,1,-1): for c in range(b+1,62): if c%b==0: g[b]-=g[c] res+=g[b] return res T=int(input()) for _ in range(T): k=int(input()) ok=10**18+100 ng=0 while ok-ng>1: mid=(ok+ng)//2 if f(mid)>=k:ok=mid else:ng=mid print(ok)