from sys import stdin input=lambda :stdin.readline()[:-1] def kth_root_int(a, k): assert 0 <= a and 0 < k if a == 0: return 0 if k == 1: return a ret = int(pow(a, 1 / k)) while pow(ret + 1, k) <= a: ret += 1 while pow(ret, k) > a: ret -= 1 return ret check=[(2, -1), (3, -1), (5, -1), (6, 1), (7, -1), (10, 1), (11, -1), (13, -1), (14, 1), (15, 1), (17, -1), (19, -1), (21, 1), (22, 1), (23, -1), (26, 1), (29, -1), (30, -1), (31, -1), (33, 1), (34, 1), (35, 1), (37, -1), (38, 1), (39, 1), (41, -1), (42, -1), (43, -1), (46, 1), (47, -1), (51, 1), (53, -1), (55, 1), (57, 1), (58, 1), (59, -1)] def count(n): res=-1 for k,sgn in check: res-=sgn*kth_root_int(n,k) return res t=int(input()) for _ in range(t): k=int(input()) ng,ok=0,k**2+1 while abs(ok-ng)>1: mid=(ok+ng)//2 if count(mid)>=k: ok=mid else: ng=mid print(ok)