import java.util.Scanner; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.ArrayList; import java.math.BigInteger; public class No1611 { public static void main(String[] args) { memo = new HashMap>(); Scanner scan = new Scanner(System.in); int T = Integer.valueOf(scan.nextLine()); List X = new ArrayList(); for (int i=0; i < T; i++) { X.add(scan.nextLine()); } scan.close(); for (String x : X) { BigInteger bi = new BigInteger(x); HashMap f = prime_factor(bi); int n = 1; for (int i : f.values()) { n *= i + 1; } BigInteger i = BigInteger.valueOf(2); while (!multiple(n, f, prime_factor(i))) { i = i.add(BigInteger.ONE); } System.out.println(bi.multiply(i)); } } private static HashMap> memo; private static HashMap prime_factor(BigInteger n) { if (memo.containsKey(n)) { return memo.get(n); } HashMap res = new HashMap(); for (BigInteger i = BigInteger.valueOf(2); i.multiply(i).compareTo(n) <= 0; i = i.add(BigInteger.ONE)) { while (n.mod(i).equals(BigInteger.ZERO)) { res.put(i, res.getOrDefault(i, 0) + 1); n = n.divide(i); } } if (!n.equals(BigInteger.ONE)) { res.put(n, res.getOrDefault(n, 0) + 1); } memo.put(n, res); return res; } private static boolean multiple(int n, HashMap f0, HashMap f1) { int y = n; for (Map.Entry entry : f1.entrySet()) { BigInteger k = entry.getKey(); int v = entry.getValue(); if (f0.containsKey(k)) { int z = f0.get(k); y = y / (z + 1) * (z + v + 1); } else { y *= v + 1; } } return n * 2 == y; } }