program messagez;
const
infile='messagez.in';
outfile='messagez.out';
var
n,m,a,b,i,j,k:longint;
map:array[1..1005,1..1005]of boolean;
begin
assign(input,infile);reset(input);
assign(output,outfile);rewrite(output);
readln(n,m);
fillchar(map,sizeof(map),false);
for i:=1 to m do begin
readln(a,b);
map[a,b]:=true;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if map[i,k] and map[k,j] then map[i,j]:=true;
for i:=1 to n do
if map[i,i] then writeln('T') else writeln('F');
close(input);close(output);
end.