#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll maxn=20;
ll cat(ll x)
{
x *= 7;
if(x <= 9)
return x;
else
{
x = (x % 10) + x/10;
if(x > 9)
return cat(x);
else
return x;
}
}
int main()
{
int n ;
cin >> n;
for(int i = 1; i <= n; i++)
{
ll ans = 0;
ll num;
cin >> num;
for(ll j = 1; num > 0;num /= 10, j++)
{
ll d=num % 10;
if(j % 2 == 0)
{
ans += d;
}
else
{
ans += cat(d);
}
}
if(ans % 8 == 0)
cout << "T" << endl;
else
cout << "F" << endl;
}
return 0;
}