var
a,b,c,d,e,f,g,h:longint;
i,q,w:string;
begin
assign(input,'abbreviation.in');
reset(input);
assign(output,'abbreviation.out');
rewrite(output);
read(h); readln;
for b:=1 to h do
begin
read(i);readln;
i:=i+' ';
for d:=1 to ord(i[0]) do
if (i[d]<='Z') and(i[d]>='A') then i[d]:=chr(ord(i[d])+32);
for c:=1 to ord(i[0]) do
if i[c]<>' ' then q:=q+i[c] else
if (ord(q[0])>=3)and(q<>'and')and(q<>'for')and(q<>'the') then
begin w:=w+chr(ord(q[1])-32);q:='';end else q:='';
writeln(w);
w:='';
i:='';
end;
close(input);
close(output);
end.