import sys from math import sqrt input = sys.stdin.readline limit = [0] * 60 for i in range(2, 60): C = 10**18 ok, ng = 0, 10**9 + 10 while ng - ok > 1: mid = (ok + ng) // 2 if mid**i <= C: ok = mid else: ng = mid limit[i] = ok + 2 def f(N): cnt = [0] * 60 for i in range(2, 60)[::-1]: ok = 0 ng = limit[i] while ng - ok > 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 # print(f(10)) def main(): K = int(input()) ok, ng = 10**18, 0 while ok - ng > 1: mid = (ok + ng) // 2 if f(mid) >= K: ok = mid else: ng = mid print(ok) if __name__ == '__main__': T = int(input()) for _ in range(T): main()