#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
while(n--){
int x;
cin>>x;
int s=0;
for(int i=1;i*i<=x;i++){//优化代码,不然会超时,比较根号x即可,中间的数字
if(x%i==0){
if(i<x) s+=i;
if(i!=x/i && x/i<x) s+= x/i;
}
}
if(s==x) cout<<x<<" is perfect"<<endl;
else cout<<x<<" is not perfect"<<endl;
}
return 0;
}