#include<cstdio>
#include<iostream>
using namespace std;
struct node {
int from,to,next;
};
struct node edge[1000001];
int n,m,num=0,head[1001],dfn[1001],low[1001];
int tarjan_dfn=0,tarjan_loop=0,loop[1001];
int stack[1001],stack_top=0,belong[1001];
bool map[1001][1001],flag[1001];
char ch;
inline void edge_add(int from,int to)
{
num++;
edge[num].to=to;
edge[num].from=from;
edge[num].next=head[from];
head[from]=num;
}
inline void qread(int &x)
{
x=0;ch=getchar();
while(ch>'9'||ch<'0') ch=getchar();
while(ch<='9'&&ch>='0'){x=x*10+(int)(ch-'0');ch=getchar();}
}
void tarjan_forloop(int serc)
{
tarjan_dfn++;
dfn[serc]=tarjan_dfn;
low[serc]=tarjan_dfn;
stack_top++;
stack[stack_top]=serc;
flag[serc]=true;
for(int i=head[serc];i!=0;i=edge[i].next)
{
if(!dfn[edge[i].to])
{
tarjan_forloop(edge[i].to);
low[serc]=min(low[serc],low[edge[i].to]);
}
else if(flag[edge[i].to]) low[serc]=min(low[serc],low[edge[i].to]);
}
if(low[serc]==dfn[serc])
{
tarjan_loop++;
while(stack[stack_top]!=serc)
{
loop[tarjan_loop]++;
belong[stack[stack_top]]=tarjan_loop;
flag[stack[stack_top]]=false;
stack_top--;
}
loop[tarjan_loop]++;
belong[stack[stack_top]]=tarjan_loop;
flag[stack[stack_top]]=false;
stack_top--;
}
}
int main()
{
int from,to;
qread(n),qread(m);
for(int i=1;i<=m;i++)
{
qread(from),qread(to);
if(map[from][to]) continue;
map[from][to]=true;
edge_add(from,to);
}
for(int i=1;i<=n;i++) if(!dfn[i]) tarjan_forloop(i);
for(int i=1;i<=n;i++)
{
if(loop[belong[i]]>1)
{
putchar('T');
putchar('\n');
}
else
{
putchar('F');
putchar('\n');
}
}
return 0;
}