#include<bits/stdc++.h>
using namespace std;
int main () {
int m;
cin >> m;
while (m--) {
int x, ans = 0,cnt=0;
cin >> x;
int xxx = x;
while (xxx) {
cnt++;
xxx/=10;
}
xxx=x;
while (xxx > 0) {
ans += pow(xxx % 10,cnt);
xxx /= 10;
}
if (ans == x)
cout << "T" << endl;
else
cout << "F" << endl;
}
return 0;
}