#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
long long a;
while (n--)
{
cin >> a;
int b = 0;
int i = 1;
while (a)
{
int num = a % 10;
if (i % 2)
{
num *= 7;
int sum = 0;
while (num > 9)
num = num % 10 + num / 10;
}
i++;
b += num;
a /= 10;
}
if (b % 8 == 0)
cout << "T\n";
else
cout << "F\n";
}
return 0;
}