#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
const int S = 20;
ll mult_mod(ll a,ll b,ll c){
while(a>=c)a -= c;
while(b>=c)b -= c;
ll ans = 0;
while(b>0){
if(b&1) ans += a;
while(ans>=c)ans -= c;
a<<=1;
while(a>=c)a-=c;
b>>=1;
}
return ans;
}
ll pow_mod(ll x,ll n,ll c){
while(x>=c)x-=c;
if(n==1)return x;
ll ans = 1;
ll tmp = x;
while(n){
if(n&1){
ans = mult_mod(ans,tmp,c);
}
tmp = mult_mod(tmp,tmp,c);
n>>=1;
}
return ans;
}
//bool check(ll a,ll n,ll x,ll t){
//}
bool Miller_Rabin(ll n){
if(n==2)return true;
if(n<2)return false;
if((n&1)==0)return false;
ll x = n-1,t = 0;
while((x&1)==0)x>>=1,t++;
for(int i=0;i<S;i++){
ll a = rand()%(n-1)+1;
ll ans = pow_mod(a,x,n);
ll last = ans;
for(ll j=1;j<=t;j++)
{
ans=mult_mod(ans,ans,n);
if(ans==1&&last!=1&&last!=n-1) return false;//合数
last=ans;
}
if(ans!=1) return false;
}
return true;
}
ll factor[100];
ll total;
ll gcd(ll a,ll b){
if(a==0)return b;
if(a<0) return gcd(-a,b);
ll t;
while(b)
{
t=a%b;
a=b;
b=t;
}
return a;
}
ll Pollard_rho(ll x,ll c){
ll i=1,k=2;
ll x0=rand()%x;
ll y=x0;
while(1)
{
i++;
x0=(mult_mod(x0,x0,x)+c)%x;
ll d=gcd(y-x0,x);
if(d!=1&&d!=x) return d;
if(y==x0) return x;
if(i==k){y=x0;k<<=1;}
}
}
void findfac(ll n){
if(Miller_Rabin(n))//素数
{
factor[total++]=n;
return;
}
ll p=n;
while(p>=n)p=Pollard_rho(p,rand()%(n-1)+1);
findfac(p);
findfac(n/p);
}
int main(){
ll t,n,i,ans;
bool flag;
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);
total = 0;
if(Miller_Rabin(n))
printf("Prime\n");
else{
findfac(n);
ans = factor[0];
for(i=1;i<total;i++){
if(factor[i]<ans){
ans = factor[i];
}
}
printf("%lld\n",ans);
}
}
return 0;
}