#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int m, n;
cin >> m;
while (m--)
{
cin >> n;
int d = log10(n) + 1; // 位数
int n1 = 0, n2 = n;
while (n)
{
n1 += pow(n % 10, d);
n /= 10;
}
if (n1 == n2)
cout << 'T' << '\n';
else
cout << "F\n";
}
return 0;
}