using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new long[t]; for (var u = 0; u < t; ++u) { var x = long.Parse(ReadLine()); ans[u] = Mul(x); } WriteLine(string.Join("\n", ans)); } static long Mul(long x) { var plist = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 }; var countb = Enumerable.Repeat(1, plist.Length).ToArray(); for (var i = 0; i < plist.Length; ++i) { var xi = x; while (xi % plist[i] == 0) { ++countb[i]; xi /= plist[i]; } } var allb = 1; foreach (var c in countb) allb *= c; for (var m = 2; m <= 31; ++m) { var count = (int[]) countb.Clone(); var tmp = m; for (var i = 0; i < plist.Length; ++i) { while (tmp % plist[i] == 0) { ++count[i]; tmp /= plist[i]; } } var all = 1; foreach (var c in count) all *= c; if (allb * 2 == all) return x * m; } return -1; } }