#t50. 自幂数判断

自幂数判断

Narcissistic Number Check

Problem Description

A "narcissistic number" (also called an Armstrong number) is an NN-digit number whose NN-th powers of its decimal digits sum to the number itself. For example, 153153 is a 33-digit number, and the sum of the cubes of its digits is 13+53+33=1531^3+5^3+3^3=153, so 153153 is narcissistic; 16341634 is a 44-digit number, and the sum of the fourth powers of its digits is 14+64+34+44=16341^4+6^4+3^4+4^4=1634, so 16341634 is narcissistic. Now, given several positive integers, determine whether each of them is a narcissistic number.

Input Format

The first line of input is a positive integer MM, the number of integers to be judged. It is guaranteed that 1≤M≤1001 \le M \le 100.

The following MM lines each contain one integer to be judged. These integers are all less than 10810^8.

Output Format

Output MM lines. For each corresponding integer, if it is a narcissistic number output the uppercase letter T, otherwise output the uppercase letter F.

Hint: you do not need to wait for all input to finish before outputting; you may judge and output each number as it is read, then read the next.

Sample Input 1

3
152
111
153

Sample Output 1

F
F
T

Sample Input 2

5
8208
548834
88593477
12345
5432

Sample Output 2

T
T
T
F
F

Sample Explanation

In the first sample, three numbers are input: 152152, 111111 and 153153. For 152152, it is a 33-digit number, and 13+53+23=1+125+8=1341^3+5^3+2^3=1+125+8=134, which is not equal to 152152, so output F. For 111111, 13+13+13=31^3+1^3+1^3=3, not equal to 111111, output F. For 153153, 13+53+33=1+125+27=1531^3+5^3+3^3=1+125+27=153, equal to itself, so output T.

Constraints

1≤M≤1001 \le M \le 100

Each integer to be judged is less than 10810^8.