#include<bits/stdc++.h>
#define ll long long
#define int long long
#define re read()
using namespace std;
const int N=3e5+5;
const int NN=3e3+5;
inline ll read(){
ll x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
int bian(int x){
x*=7;
if(x<=9)return x;
while(x>9){
x=x%10+x/10%10+x/100%10+x/1000%10+x/10000%10+x/100000%10+x/1000000%10+x/10000000%10+x/100000000%10+x/1000000000%10+x/10000000000%10+x/10000000000%10+x/100000000000%10+x/1000000000000%10;
if(x<=9)return x;
}
}int l;
void pd(string &x){
for(int i=0;i<l;i+=2){
x[i]=(char)bian((int)x[i]-'0')+'0';
}
}
signed main(){
ios::sync_with_stdio(false);
int n=re;
for(int i=1;i<=n;i++) {
string x;
cin>>x;
l=x.size() ;
pd(x);
int c=0;
int ii=0;
while(ii<l){
c+=(int)x[ii]-'0';
ii++;
}
if(c%8==0)cout<<'T'<<'\n';
else cout<<'F'<<'\n';
}
return 0;
}