include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
int main() {
int n;
cin >> n;
long x;
int sum = 0;
while (n–) {
cin >> x;
for (int i = 1; i * i < x; i++) {
if (x % i == 0) {
if(i * i < x) {
sum += i;
if(i != 1) {
sum += (x / i);
}
}
}
}
if (sum == x) {
cout << x << " is perfect" << endl;
} else {
cout << x << " is not perfect" << endl;
}
sum = 0;
}
return 0;
}