#include <iostream>
using namespace std;
int main(){
int n,b;
bool a=false;
int num=1;
long long res=0;
cin>>n;
for(int i=1;i<=n;i++){
a=false;
num=1;
res=0;
cin>>b;
if(b==1||b==0){
cout<<'T';
continue;
}
for(int k=1;k<=9;k++){
res=0;
for(long long j=1;j<=100000000;j*=10){
num=1;
for(int x=1;x<=k;x++){
num*=(b/j%10);
}
res+=num;
}
if(res==b){
cout<<'T'<<endl;
a=true;
}
}
if(a!=true){
cout<<'F'<<endl;
}
}
return 0;
}