from collections import defaultdict def prime_factorization(n): arr = defaultdict(int) for i in range(2, int(n**0.5)+1): while n % i == 0: arr[i] += 1 n //= i if n != 1: arr[n] += 1 return arr t = int(input()) ans = [] primes = [2, 3, 5, 7, 11, 13, 17, 23, 29, 31] options = [prime_factorization(i) for i in range(0, 32)] for i in range(t): x = int(input()) d = defaultdict(int) for p in primes: temp = x while temp % p == 0: d[p] += 1 temp //= p for i in range(2, 32): xnum = 1 opnum = 1 for p in options[i]: xnum *= (d[p]+1) opnum *= (d[p] + options[i][p] + 1) if 2*xnum == opnum: break print(i*x)