#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
#define MAX ((long long)1<<61)
#define Times 11
typedef long long ll;
ll s[501];
ll minn;
int num=0;
ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
ll random(ll n)
{
return (long long)((double)rand()/RAND_MAX*n+0.5);
}
ll mul_mod(ll a,ll b,ll m)
{
ll t=a%m,res=0;
b%=m;
while(b)
{
if(b&1)
{
res+=t;
if(res>m) res-=m;
}
t<<=1;
if(t>m) t-=m;
b>>=1;
}
return res;
}
ll pow_mod(ll a,ll b,ll m)
{
ll t=a%m,res=1;
while(b)
{
if(b&1)
res=mul_mod(res,t,m);
t=mul_mod(t,t,m);
b>>=1;
}
return res;
}
bool Wit(ll a,ll n)
{
ll m=n-1;
int j=0;
while(!(m&1))
{
j++;
m>>=1;
}
ll x=pow_mod(a,m,n);
if(x==1||x==n-1)
return true;
while(j--)
{
x=x*x%n;
if(x==n-1)
return true;
}
return false;
}
bool Miller(ll n)
{
if(n<2) return false;
if(n==2) return true;
if(!(n&1)) return false;
for(int i=1;i<=Times;i++)
{
ll a=random(n-2)+1;
if(!Wit(a,n)) return false;
}
return true;
}
ll Pollard(ll n,int c)
{
ll x,y,d,i=1,k=2;
x=random(n-1)+1;
y=x;
while(1)
{
i++;
x=(mul_mod(x,x,n)+c)%n;
d=gcd(y-x,n);
if(1<d&&d<n)
return d;
if(y==x)
return n;
if(i==k){
y=x;
k<<=1;
}
}
}
void Find(ll n,int k)
{
if(n==1) return;
if(Miller(n))
{
s[++num]=n;
if(n<minn)
minn=n;
return ;
}
ll p=n;
while(p>=n)
p=Pollard(p,k--);
Find(p,k);
Find(n/p,k);
}
int main()
{
int t;
ll n;
cin>>t;
while(t--)
{
cin>>n;
minn=MAX;
if(Miller(n))
cout<<"Prime\n";
else{
Find(n,201);
cout<<minn<<endl;
}
}
return 0;
}