#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,i,j,sum,x,c=0;
while(cin>>n)
{
if(n==0)
{
break;
}
if(c==0)
cout<<"PERFECTION OUTPUT"<<endl;
x=sqrt(n);
if(x*x==n &&n!=1)
sum=x;
else
{
sum=0;
x=1;
}
if(n!=1)
{
for(i=2; i*i<n; i++)
{
if(n%i==0)
{
sum+=i+(n/i);
//cout<<sum<<" "<<i<<" "<<n/i<<endl;
}
}
sum+=1;
}
//cout<<sum<<" "<<n<<endl;
if(sum==n)
printf("%5d PERFECT\n",n);
else if(sum>n)
printf("%5d ABUNDANT\n",n);
//cout<<n<<" ABUNDANT"<<endl;
else
printf("%5d DEFICIENT\n",n);
c++;
}
cout<<"END OF OUTPUT"<<endl;
return 0;
}