#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,a,sum;
cin>>n;
for(int i=0;i<n;i++)
{
sum=0;
cin>>a;
for(int j=1;j*j<=a;j++)
{
if(a%j==0)
{
if(j<a) sum+=j;//排除a=1
if(a/j!=j&&a/j<a) sum+=a/j;//不加1*a=a这一项
}
}
if(sum==a) cout<<a<<" is perfect"<<endl;
else cout<<a<<" is not perfect"<<endl;
}
}