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