#include <bits/stdc++.h>
using namespace std;
int a[10005],b[10005];
int main()
{
int n;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> a[i];
}
for(int i=0;i<n;i++)
{
int q=0,j=0;
while(a[i]>0)
{
b[q]=a[i]%10;
a[i]=a[i]/10;
q++;
}
for(int l=0;l<q;l++)
{
if(b[l]%2!=0)
{
int w=0;
b[l]=b[l]*7;
while(b[l]>9)
{
if(b[l]>9)
{
int e=b[l],r=0;
while(e>0)
{
r=r+e%10;
e=e/10;
}
b[l]=r;
}
}
}
j=j*10+b[l];
}
int y=0;
while(j>0)
{
y=y+j%10;
j=j/10;
}
if(y%8==0)
cout << 'T' << endl;
else
cout << 'F' << endl;
}
return 0;
}