#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include<numeric>
using namespace std;
int main()
{
vector<int> inputNums;
vector<int> results;
while (true)
{
int num;
scanf_s("%d", &num);
if (num == 0)
{
break;
}
inputNums.push_back(num);
}
for (int i = 0; i < inputNums.size(); i++)
{
int num = inputNums[i];
vector<int> divisors;
for (int j = 1; j < (num / 2 + 1); j++)
{
if (num % j == 0)
{
divisors.push_back(j);
}
}
int sum = std::accumulate(divisors.begin(), divisors.end(), 0);
int result;
if (num > sum)
{
result = 1;
}
else if (num < sum)
{
result = -1;
}
else
{
result = 0;
}
results.push_back(result);
}
printf("PERFECTION OUTPUT\n");
for (int i = 0; i < results.size(); i++)
{
int result = results[i];
if (result>0)
{
printf("%5d DEFICIENT\n",inputNums[i]);
}
else if (result == 0)
{
printf("%5d PERFECT\n", inputNums[i]);
}
else
{
printf("%5d ABUNDANT\n", inputNums[i]);
}
}
printf("END of OUTPUT\n");
return 0;
}