import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] primes = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}; int[][] counts = new int[32][primes.length]; for (int i = 2; i <= 31; i++) { int x = i; for (int j = 0; j < primes.length && x > 1; j++) { while (x % primes[j] == 0) { x /= primes[j]; counts[i][j]++; } } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { long x = sc.nextLong(); long y = x; int[] base = new int[primes.length]; long target = 1; for (int j = 0; j < primes.length; j++) { while (y % primes[j] == 0) { base[j]++; y /= primes[j]; } target *= base[j] + 1; } long ans = Long.MAX_VALUE; for (int j = 2; j <= 31; j++) { long tmp = 1; for (int k = 0; k < primes.length; k++) { tmp *= base[k] + counts[j][k] + 1; } if (target * 2 == tmp) { ans = j; break; } } sb.append(x * ans).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }