#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n,x,sum=0;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> x;
if(x==1) cout << x << " is not perfect" << endl;
else
{
sum+=1;
for(int j=2;j<=sqrt(x);j++)
{
if(x%j==0)
{
int y=x/j;
if(y==j) sum=sum+j;
else sum=sum+j+x/j;
}
}
if(sum==x) cout << x << " is perfect" << endl;
else cout << x << " is not perfect" << endl;
}
sum=0;
}
return 0;
}