# n 以下の累乗数の個数 def f(n): cnt = [0] * 62 for i in range(61, 1, -1): ok, ng = 0, int((10 ** 18 + 500) ** (1 / i)) + 1 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, 10 ** 18 while ok - ng > 1: mid = (ok + ng) // 2 if f(mid) >= k: ok = mid else: ng = mid print(ok)