#include<bits/stdc++.h>
using namespace std;
int n,x;
bool op(int N)
{
int p=0,sum=0,b=0;
while(N)
{
N/=10;
p++;//记录有多少位
}
while(N)
{
b=N%10;
sum+=pow(b,p);//p为位数,逐位运算求和
N/=10;
}
if(sum==N)
{
return true;
}
else
{
return false;
}
}
int main()
{
std::cin>>n;
for(int i=1;i<=n;i++)
{
cin>>x;
if(op(x)==true) std::cout<<"T";
else std::cout<<"F";
}
return 0;
}