import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) sys.setrecursionlimit(10**7) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### p = [] MAX = 63 arr = [-1] * (MAX + 1) for i in range(2, int(MAX**0.5)+1): if arr[i]!=-1: continue j = 1 p.append(i) while i * j < len(arr): if arr[i * j] < 0: arr[i * j] = i j += 1 for i in range(2, len(arr)): if arr[i]==-1: p.append(i) def g(x,n): ng = 10**9 ok = 0 while ng-ok>1: d = (ok+ng)//2 if d**x<=n: ok = d else: ng = d return ok """ def g(x,n): c = int(n**(1/x))-1 return max([i for i in range(c,c+3) if pow(i,x)<=n]) """ def f(x): r = 1 for q in p: if pow(2,q)>x: break elif pow(3,q)>x: r+=1 continue r+=g(q,x)-1 #print(x,r) return r>=K T = ni() for i in range(T): K = ni() ok = 10**18 ng = 0 while ok-ng>1: d = (ok+ng)//2 if f(d): ok = d else: ng = d print(ok)