import math def cnt_i(x,i): y = math.floor(pow(x,1/i)) for j in range(y+2,y-3,-1): if j**i <= x: return j-1 def f(x,k): ju = 0 cnt = [0 for _ in range(61)] for i in range(60,1,-1): c = cnt_i(x,i) for j in range(2*i,61,i): c -= cnt[j] cnt[i] = c ju += c if ju >= k-1: return True else: return False def solve(): k = int(input()) ng = 0 ok = 10**18+1 while ok-ng > 1: mid = (ok+ng)//2 if f(mid,k): ok = mid else: ng = mid print(ok) t = int(input()) for _ in range(t): solve()