uCoder | 1179 | Nível: 4 | Tempo Limite: 10

Armstrong Numbers

Adaptado por erich.rodriguesf

Competição: Interfatecs 2015

An integer number is known as an Armstrong Number when we take each one of its digits to the power of an integer n and with the sum of the results we get the original number. For example, 153 is an Armstrong Number with base 3, because 1^{3} + 5^{3} + 3^{3} = 1 + 125 + 27 = 153. The integer 54748 is an Armstrong Number with base 5 because 5^{5} + 4^{5} + 7^{5} + 4^{5} + 8^{5} = 3125 + 1024 + 16807 + 1024 + 32768 = 54748. Your task in this problem is to verify if an integer number is a rare Armstrong Number.

## Entrada

The input has many integers between 2 and 1000000000, each number must be verified if it is an Armstrong Number in some base. Consider in this problem that we want to identify numbers that fits the criteria described above only on bases bigger than 1 and smaller than 10. The program should finish reading the input after a zero is read.

## Saída

For each test case, print a letter N (uppercase) if the integer read isn´t an Armstrong Number with base between 2 and 9. Otherwise, print the base found for the input. If it was possible to find an Armstrong Number with more than one base, print the smallest.

Exemplo de Entrada | Exemplo de Saída |
---|---|

1234 |
N |