#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a,b,e=1;
cin>>a;
for(int c=1;c<=a;c++)
{
cin>>b;
e=1;
for(int d=2;d<b;d++)
{
if(b%d==0)
{
e+=d;
}
}
if(e==b&&b!=1)
{
printf("%d is perfect\n",b);
if(b==1) cout<<"1 is not perfect"<<endl;
}
else printf("%d is not perfect\n",b);
}
}