#t129. 幸运数

幸运数

Lucky Number

Problem Description

Xiaoming invented a kind of "lucky number". For a positive integer, its even positions stay unchanged (the units digit is position 11, the tens digit is position 22, and so on), while its odd positions are transformed as follows: multiply the digit by 77; if the result is not greater than 99, use it as the transformed result; otherwise add up the digits of the result, and if that sum is not greater than 99, use it as the transformed result; otherwise (the sum is still greater than 99) keep adding the digits until the result is not greater than 99, and use that as the transformed result. After the transformation, add up the digits of the transformed result; if the sum is a multiple of 88, the original positive integer is called a lucky number.

For example, for 1634716347: the 11st digit is 77, multiplied by 77 gives 4949, which is greater than 99; adding its digits gives 1313, still greater than 99; adding again gives 44 as the final result. The 33rd digit is 33, transformed to 33. The 55th digit is 11, transformed to 77. The final transformed result is 7634476344, whose digit sum is 2424, a multiple of 88. Therefore 1634716347 is a lucky number.

The corresponding multiple-choice and true/false questions can be found at https://ti.luogu.com.cn/problemset/1126 .

Input Format

The first line contains a positive integer NN, the number of positive integers to be judged. It is guaranteed that 1≤N≤201 \leq N \leq 20.

The following NN lines, starting from line 22, each contain one positive integer to be judged. These positive integers are guaranteed to be less than 101210^{12}.

Output Format

Output NN lines, indicating whether each of the NN positive integers is a lucky number: if yes output T, otherwise output F.

Hint: you do not need to wait for all input to finish before outputting in order; you may read a number, judge it, output the result, then read the next number.

Sample Input

2
16347
76344

Sample Output

T
F

Sample Explanation

For the first positive integer to be judged, 1634716347, its odd positions are transformed while even positions stay unchanged, yielding 7634476344, whose digit sum is 2424, a multiple of 88, so it is a lucky number and T is output. For the second positive integer to be judged, 7634476344: the units digit (position 11) 44 multiplied by 77 gives 2828, 2+8=102 + 8 = 10 is still greater than 99, adding again gives 11, transformed to 11; the tens digit 44 stays unchanged; the hundreds digit 33 multiplied by 77 gives 2121, 2+1=32 + 1 = 3, transformed to 33; the thousands digit 66 stays unchanged; the ten-thousands digit 77 multiplied by 77 gives 4949, 4+9=134 + 9 = 13, 1+3=41 + 3 = 4, transformed to 44. Combining them gives 4634146341, whose digit sum is 4+6+3+4+1=184 + 6 + 3 + 4 + 1 = 18, not a multiple of 88, so it is not a lucky number and F is output.

Constraints

  • 1≤N≤201 \leq N \leq 20
  • Each positive integer to be judged is <1012< 10^{12}