from collections import Counter import math def prime_numbers(x): if x < 2: return [] prime_numbers = [i for i in range(x)] prime_numbers[1] = 0 for prime_number in prime_numbers: if prime_number > math.sqrt(x): break if prime_number == 0: continue for composite_number in range(2 * prime_number, x, prime_number): prime_numbers[composite_number] = 0 return [prime_number for prime_number in prime_numbers if prime_number != 0] primes = prime_numbers(10 ** 2) def soinnsuu(x): s = [] for i in primes: if i > int(math.sqrt(x)): break elif x % i == 0: while x % i == 0: x //= i s.append(i) if not x == 1: s.append(x) return s def main(): import sys input = sys.stdin.buffer.readline for _ in range(int(input())): x = int(input()) d = Counter(soinnsuu(x)) cnt = 1 for k, v in d.items(): cnt *= v + 1 for i in range(2, 32): d2 = Counter(soinnsuu(i * x)) cnt2 = 1 for k, v in d2.items(): cnt2 *= v + 1 if cnt2 == cnt * 2: print(i * x) break if __name__ == '__main__': main()