Problem E: 【GESP4】幸运数

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:75 Solved:33

Description

小明发明了一种 "幸运数"。一个正整数,其偶数位不变(个位为第 lns="http://www.w3.org/1998/Math/MathML">1 位,十位为第 lns="http://www.w3.org/1998/Math/MathML">2 位,以此类推),奇数位做如下变换:将数字乘以 lns="http://www.w3.org/1998/Math/MathML">7,如果不大于 lns="http://www.w3.org/1998/Math/MathML">9 则作为变换结果,否则把结果的各位数相加,如果结果不大于 lns="http://www.w3.org/1998/Math/MathML">9 则作为变换结果,否则(结果仍大于 lns="http://www.w3.org/1998/Math/MathML">9)继续把各位数相加,直到结果不大于 lns="http://www.w3.org/1998/Math/MathML">9,作为变换结果。变换结束后,把变换结果的各位数相加,如果得到的和是 lns="http://www.w3.org/1998/Math/MathML">8 的倍数,则称一开始的正整数为幸运数。

例如,lns="http://www.w3.org/1998/Math/MathML">16347:第 lns="http://www.w3.org/1998/Math/MathML">1 位为 lns="http://www.w3.org/1998/Math/MathML">7,乘以 lns="http://www.w3.org/1998/Math/MathML">7 结果为 lns="http://www.w3.org/1998/Math/MathML">49,大于 lns="http://www.w3.org/1998/Math/MathML">9,各位数相加为 lns="http://www.w3.org/1998/Math/MathML">13,仍大于 lns="http://www.w3.org/1998/Math/MathML">9,继续各位数相加,最后结果为 lns="http://www.w3.org/1998/Math/MathML">4;第 lns="http://www.w3.org/1998/Math/MathML">3 位为 lns="http://www.w3.org/1998/Math/MathML">3,变换结果为 lns="http://www.w3.org/1998/Math/MathML">3;第 lns="http://www.w3.org/1998/Math/MathML">5 位为 lns="http://www.w3.org/1998/Math/MathML">1,变换结果为 lns="http://www.w3.org/1998/Math/MathML">7。最后变化结果为 lns="http://www.w3.org/1998/Math/MathML">76344,对于结果 lns="http://www.w3.org/1998/Math/MathML">76344 其各位数之和为 lns="http://www.w3.org/1998/Math/MathML">24,是 lns="http://www.w3.org/1998/Math/MathML">8 的倍数。因此 lns="http://www.w3.org/1998/Math/MathML">16347 是幸运数。

Input

输入第一行为正整数 lns="http://www.w3.org/1998/Math/MathML">,表示有 lns="http://www.w3.org/1998/Math/MathML"> 个待判断的正整数。约定 lns="http://www.w3.org/1998/Math/MathML">120

从第 lns="http://www.w3.org/1998/Math/MathML">2 行开始的 lns="http://www.w3.org/1998/Math/MathML"> 行,每行一个正整数,为待判断的正整数。约定这些正整数小于 lns="http://www.w3.org/1998/Math/MathML">1012

Output

输出  行,对应 个正整数是否为幸运数,如是则输出 'T',否则输出 'F'。

提示:不需要等到所有输入结束在依次输出,可以输入一个数就判断一个数并输出,再输入下一个数。


Sample Input Copy

2
16347
76344

Sample Output Copy

T
F

HINT

1=<N<=20;  待判断的正整数小于10^12。