#define int long long mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
intgcd(int a, int b){ if (!b) return a; returngcd(b, a % b); }
intqmi(int a, int k, int p){ int res = 1; while (k) { if (k & 1) res = (__int128)res * a % p; a = (__int128)a * a % p; k >>= 1; } return res; }
intrho(int n){ if (n % 2 == 0) return2; int c = uniform_int_distribution<int>(1, n-1)(rng); auto f = [=](int x){ return ((__int128)x * x + c) % n; }; int x = 0, y = f(x); while (x != y) { int d = gcd(abs(x - y), n); if (d > 1) return d; x = f(x), y = f(f(y)); } return n; }
booltest(int a, int u, int k, int n){ int v = qmi(a, u, n); if (v == 1 || v == 0 || v == n-1) returntrue; for (int i = 1; i <= k; i++) { v = (__int128)v * v % n; if (v == n-1 && i != k) returntrue; if (v == 1) returnfalse; } returnfalse; }
boolmr(int n){ staticint bases[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; if (n < 3 || n % 2 == 0) return n == 2; int u = n-1, k = 0; while (u % 2 == 0) u /= 2, k++; for (int a: bases) if (!test(a, u, k, n)) returnfalse; returntrue; }
intsolve(int n){ static map<int, int> mp; if (mp.count(n)) return mp[n];
if (mr(n)) return mp[n] = n; int x = n; while (x == n) x = rho(n); return mp[n] = max(solve(x), solve(n / x)); }
signedmain(){ int n, x, t; read(t); while (t--) read(n), ((x = solve(n)) == n) ? write("Prime") : write(x); return0; }