#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; i++)
{
int x;
cin >> x;
int sum = 0;
for(int j = 1; j * j <= x; j++)
{
if(x % j == 0)
{
if(j < x) sum += j; // 相当于特判了1
if(x / j < x && j * j != x) sum += x/ j;
}
}
if(sum == x) cout << x << " is perfect" << endl;
else cout << x << " is not perfect" << endl;
}
return 0;
}