#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,t,sum,len,ans;
string s;
signed main()
{
cin >> n;
while(n--)
{
cin >> s;
len = s.length();
for(int i = len - 1; i >= 0; i--)
{
t = s[i] - '0';
if(i % 2 == 0)
{
if(t * 7 > 9)
{
t *= 7;
do
{
sum = 0;
for(int j = t; j > 0; j /= 10)
{
sum += j % 10;
}
t = sum;
}
while(t > 9);
ans += t;
}
else
{
ans += t * 7;
}
}
else
{
ans += t;
}
}
if(ans % 8 == 0) cout << "T\n";
else cout << "F\n";
}
return 0;
}