const
d:string=('abcdefghijklmnopqrstuvwxyz');
var
n,i,j,k,st,et:integer;
s,p:string;
f,g:text;
begin
assign(f,'abbreviation.in');
assign(g,'abbreviation.out');
reset(f);
rewrite(g);
readln(f,n);
for i:=1 to n do
begin
j:=0;
readln(f,s);
repeat
j:=j+1;
if s[j]<>' ' then begin
st:=j;
repeat
j:=j+1;
until (j=length(s)+1)or(s[j]=' ');
et:=j-1;
p:=copy(s,st,et-st+1);
if (length(p)>=3)and
(p<>'and')and(p<>'anD')and(p<>'aNd')and(p<>'aND')and
(p<>'And')and(p<>'AnD')and(p<>'ANd')and(p<>'AND')and
(p<>'for')and(p<>'foR')and(p<>'fOr')and(p<>'fOR')and
(p<>'For')and(p<>'FoR')and(p<>'FOr')and(p<>'FOR')and
(p<>'the')and(p<>'thE')and(p<>'tHe')and(p<>'tHE')and
(p<>'The')and(p<>'ThE')and(p<>'THe')and(p<>'THE')
then if pos(s[st],d)<>0 then write(g,chr(ord(s[st])-32))
else write(g,s[st]);
end;
until j=length(s)+1;
writeln(g);
end;
close(f);
close(g);
end.