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