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") no = lambda :print("no");No = lambda :print("No") ####################################################################### pl = [2,3,5,7,11,13,17,19,23,29,31,37,41,43] dl = dict() for i, x in enumerate(pl): dl[x] = i z = len(pl) T = ni() def f(x,y): r = 0 while x>0: if x%y: break x//=y r+=1 return r for i in range(T): x = ni() ans = 10**15 for j in pl: ff = f(x,j) ans = min(ans,pow(j,ff+1)) print(x*ans)