# 二分探索の上限をあらかじめ求めておく lim=[0]*60 for i in range(2,60): lim[i]=int((10**18+10000)**(1/i)) def f(n): cnt=[0]*60 for i in range(59,1,-1): ng,ok=lim[i]+1,0 # floor(n^(1/i)) を二分探索で求める while abs(ok-ng)>1: mid=(ok+ng)//2 if mid**i<=n: ok=mid else: ng=mid ok-=1 # 約数包除 cnt[i]=ok-sum(cnt[::i]) return sum(cnt)+1 t=int(input()) for _ in range(t): k=int(input()) ng,ok=0,k**2+1 # f(n)>=k となる最小の n を二分探索で求める while abs(ok-ng)>1: mid=(ok+ng)//2 if f(mid)>=k: ok=mid else: ng=mid print(ok)