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}; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { long x = sc.nextLong(); long y = x; long ans = Long.MAX_VALUE; for (int j = 0; j < primes.length; j++) { int count = 0; while (y % primes[j] == 0) { count++; y /= primes[j]; } if (count == 0) { if (ans > primes[j]) { ans = primes[j]; } break; } else { ans = Math.min(ans, (long)Math.pow(primes[j], count + 1)); } } sb.append(ans * x).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(); } }