program p1;
var
s,q:string;
a,b,c,d,n:longint;
procedure bd(var x:string);
var
a,b:longint;
begin
for a:=1 to length(x) do
if (x[a]>='a') and (x[a]<='z') then x[a]:=chr(ord(x[a])-32);
end;
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+' ';
bd(s);
q:='';
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.