#include <iostream>
using namespace std;
bool check(int x){
int sum;
if(x == 1) sum = 0;
else sum = 1;
for(int i = 2; i <= x / i; i ++ ){
if(!(x % i)){
sum += i;
if(i * i != x) sum += x / i;
}
}
return sum == x;
}
int main(){
int n; cin >> n;
for(int i = 0; i < n; i ++ ){
int m; cin >> m;
if(check(m)) cout << m << " is perfect" << endl;
else cout << m << " is not perfect" << endl;
}
return 0;
}