#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,x;
cin>>n;
while(n--){
cin>>x;
int sum=0;
for(int i=1;i<=sqrt(x);i++){
if(x%i==0){
if(i<x) sum+=i;//排除x==1
if(i!=x/i&&x/i<x) sum+=x/i;//x的两个因数不等时,i是较小因数,再加上较大因数,如果两因数等就只加一个
}
}
if(sum==x){
cout<<x<<" is perfect"<<endl;
}
else cout<<x<<" is not perfect"<<endl;
}
return 0;
}