1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10490 - Mr. Azad and his Son!!!!!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1431
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Precomputed
* Status : Accepted
* Runtime: 0.108
*/

/* Numbers are found by a brute force generator (c++)

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
long long sum, n, j, squareRoot;
for(int i = 1; i < 32; i++)
{
cout << i+1 << " ";
n = (long long)(2 << (i-1)) * ((long long)(2 << i) - 1);
cout << n << " ";

sum = 1;
squareRoot = (long long)sqrt(n);
for(j = 2; j <= squareRoot; j++)
if(n % j == 0)
sum += j + (n/j);


if(squareRoot * squareRoot == n)
sum -= squareRoot;

cout << sum << " " << (sum == n) << endl;


}
return 0;
}

*/


import java.io.*;
import java.util.*;

public class Main {

private static List<Integer> factors = new ArrayList<Integer>();
private static long sum;


public static void main(String...args)
{
Scanner sc = new Scanner(System.in);
int k;

// see c++ generator
Set<Integer> primes = new HashSet<Integer>();
primes.add(2);
primes.add(3);
primes.add(5);
primes.add(7);
primes.add(11);
primes.add(13);
primes.add(17);
primes.add(19);
primes.add(23);
primes.add(29);
primes.add(31);


while(( k = sc.nextInt()) != 0)
{
if(!primes.contains(k))
System.out.println("Given number is NOT prime! NO perfect number is available.");
else
if(k == 29 || k == 11 || k == 23)
System.out.println("Given number is prime. But, NO perfect number is available.");
else
System.out.println("Perfect: " + ((2l << (k-2))*((2l << (k-1))-1)) + "!");
}
}
}