## Description:

A Happy Number can be defined as follows. From a positive integer n, calculate the sum of square
of each digit of n. Then from that sum, repeat the same process over and over again. This cycle
terminates if and only if there is 1 in the sequence. Hence, we call the number n a happy number if it
generates a finite sequence. Otherwise, the endless cycle occurs (1 never appears in the sequence). We

may call the number generating an endless cycle an unhappy number . Observe the following
examples:

700 is a happy number72+02 +02 =49
12 +32 +02 =10

2 is not a happy number

22=4

32 +72 =58

12 +42 +52=42

42 = 16 ... and never terminates

42 +92 =97
12 +02 =1

92 +72 =130

12+62=37
82 +92 =14
22 +02 =4

42 =16

52 +82 =89
42 +22 =20

A Prime Number is an integer greater than 1 that can be divided only by 1 and itself. Here are some
prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, ...

A Happy Prime Number is a prime number which also satisfies the happy number condition such as 7,
13, 19, ...

Your task is to write a program to show all happy prime numbers less than or equal to a given numbern. (10 ≤ n ≤ 1000000)

## Input:

A positive number n is the only input of the program

## Output:

the program prints all happy numbers in ascending order, one number in a line.

## Sample Input:

20

## Sample Output:

7

13

19

## Note:

用于 NUPT ACM 2010 Personal Ranking Contest 5

本题由旧版NOJ导入，来源：The 1st ACM-ICPC Thailand National Programming Contest 2009