f:text;
st:array[1..100]of string;
i,n,j:integer;
begin
writeln('vvedite kolichestvo strok');
readln(n);
for i:=1 to n do
begin
writeln('vvedite stroku nomer ',i);
readln(st[i]);
end;
for i:=1 to n do
for j:=length(st[i])-3 downto 1 do
begin
if (copy(st[i],j,5)=' дом ')then insert(' большой',st[i],j);
if (copy(st[i],j,4)='дом ')and(j=1) then insert('большой ',st[i],j);
if (copy(st[i],j,4)=' дом')and(j=length(st[i])-3 )then insert(' большой',st[i],j);
end;
assign(f,'output.txt');
rewrite (f);
for i:=1 to n do
writeln(f,st[i]);
close(f);
end.