#include<iostream>
#include<cmath>
using namespace std;
int n, x, arr[19];
int nod(int num) {
int sum = 0;
while (num) {
sum++;
num /= 10;
}
return sum;
}
int main() {
cin >> n;
while (n--) {
cin >> x;
int s = 0;
while (x) {
s += pow(x % 10, nod(x));
x /= 10;
}
cout << (s == x ? 'T' : 'F') << endl;
}
return 0;
}