uses crt;
var d,f:text; n,i,j:longint; s:string;
begin
clrscr;
assign(d,'input.pas');reset(d);
assign(f,'output.pas');rewrite(f);
readln(d,n);
for j:=1 to n do
begin
readln(d,s);
i:=1;
repeat
inc(i);
if s[i]='?' then begin delete(s,i-1,2); i:=1; i:=1; end;
if (s[i]='*')and(i>2) then begin delete(s,i-2,3); i:=1; end;
if (s[i]='_')or(s[i]='#') then begin s[i-1]:=' '; delete(s,i,1); i:=1; end;
until i>=length(s);
writeln(f,s);
end;
close(f);
close(d);
end.
///////////////////////////////////////////////////////
Bài này mình cũng có trả lời bên kia rồi nên không phải là copy đây nhé!