#include <bits/stdc++.h>
using namespace std;
int n, m, sum, p;
int main() {
scanf("%d", &m);
while(m--) {
scanf("%d", &n);
int temp = n;
while(temp) {
temp /= 10;
p++;
}
temp = n;
while(temp) {
sum += pow(temp % 10, p);
temp /= 10;
}
if(sum == n)
printf("T\n");
else
printf("F\n");
}
return 0;
}