#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,k;
cin>>a;
for(int i=1;i<=a;i++){
k=0;
c=0;
cin>>b;
d=b;
e=d;
while(e!=0){
e=e/10;
k++;
}
while(b!=0){
c=c+pow(b%10,k);
b=b/10;
}
if(c==d){
cout<<"T"<<endl;
}
else{
cout<<"F"<<endl;
}
}
return 0;
}