Happy Prime

No attempts yetTime limit1sMemory limit256 MB

Problem

Replace a number by the sum of the squares of its digits, then repeat. If the process reaches 1, the number is happy. For example, 7 becomes 49, then 97, then 130, then 10, then 1, so 7 is happy. A number that never reaches 1 falls into a cycle that repeats the same values forever. A happy prime is a number that is both happy and prime.

Decide whether the given MM is a happy prime.

Input

The first line contains the number of test cases PP. (1P10001 \le P \le 1000)

Each of the next PP lines contains a case number and an integer MM, separated by a single space. (1M100001 \le M \le 10000) The case number is taken from the input as written. It is not guaranteed to start at 1 or to increase by one.

Output

For each test case, print one line holding the case number given in the input, then MM, then YES if MM is a happy prime and NO otherwise, separated by single spaces.