# Xを素因数分解 # 既存素因数のべき乗を倍にするか、ない素因数を加える # 10**11ということは37までに存在しない素因数があるはず # 2*3*5*7*11*13*17*19*23*29*31*37 = 7*10**12 # いや、Xを素因数分解すると間に合わないだろう # 必要なのは37までの素因数の有無 T = int(input()) for t in range(T): primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41] X = int(input()) ans_multiple = 41 for p in primes: c = 0 x = X while x%p == 0: x //= p c += 1 if c == 0: ans_multiple = min(ans_multiple, p) break else: if p == 2: if c == 1: ans_multiple = min(ans_multiple, 2**2) elif c == 2: # 危ない危ない、乗数を1間違えてた ans_multiple = min(ans_multiple, 2**3) elif p == 3: if c == 1: ans_multiple = min(ans_multiple, 3**2) #print('p', p, 'c', c) ans = X*ans_multiple print(ans)