#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n;
while(n--)
{
int sum=1,i;
cin>>m;
if(m==1) //值为1 ,则为非完全数
{
printf("%d is not perfect\n",m);
continue;
}
else
{
for( i=2;i<=sqrt(m);i++)
{
if(m%i==0 && i==sqrt(m)) //m为完全开方数,则i和 m/i只需加一个
{sum+=i;break;}
if(m%i==0)
sum+=i+m/i;
}
if(sum==m)
printf("%d is perfect\n",m);
else
printf("%d is not perfect\n",m);
}
}
return 0;
}