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