var
a,c:string;
d:array[1..100] of string;
b:char;
i,j,t,s,x:integer;
begin
assign(input,'abbreviation.in');
assign(output,'abbreviation.out');
reset(input);
rewrite(output);
readln(t);
for i:=1 to t do
begin
readln(a);
s:=length(a);
a:=upcase(a);
for j:=1 to s+1 do
begin
if (a[j]=' ')or (j=s+1) then
begin
if (c='THE') or (c='FOR') or(c='AND') or (length(c)<3) then
else
d[i]:=d[i]+c[1];
c:='';
end
else
c:=c+a[j];
end;
a:='';
end;
for i:=1 to t do
writeln(d[i]);
close(input);
close(output);
end.