#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while (n--)
{
int x;
int s=1;
cin>>x;
for(int i = 2; i<= x/i; i++){
if (x % i == 0) {
s+=i;
s+=x/i;
}
}
if(s==x && x>1)
printf("%d is perfect\n",x);
else
printf("%d is not perfect\n",x);
}
return 0;
}