#include<bits/stdc++.h>
using namespace std;
int aaa(int x){
x*=7;
while(x>9){
int s=0;
while(x>0){
s+=x%10;
x=x/10;
}
x=s;
}
return x;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
char x[25];
int a[25];
cin>>x;
int m=strlen(x);
for(int j=0;j<m;j++){
a[j]=x[j]-'0';
}
for(int j=0;j<m;j++){
if(j%2==0){
a[j]=aaa(a[j]);
}
}
int s=0;
for(int j=0;j<m;j++){
s+=a[j];
}
if(s%8==0){
cout<<"T\n";
}else{
cout<<"F\n";
}
}
return 0;
}