var
s,q:string;
a,b,i,j,n:longint;
begin
assign(input,'abbreviation.in');
reset(input);
assign(output,'abbreviation.out');
rewrite(output);
readln(n);
for a:=1 to n do
begin
readln(s);
s:=s+' ';
q:='';
for b:=1 to length(s) do
if (s[b]>='a') and (s[b]<='z') then
s[b]:=chr(ord(s[b])-32);
for b:=1 to length(s) do
if s[b]<>' '
then
q:=q+s[b]
else
begin
if (q<>'AND') and (q<>'FOR') and (q<>'THE') and (length(q)>=3)
then
write(q[1]);
q:='';
end;
writeln;
end;
close(input);
close(output);
end.