var c:char;s,t:string(9999)=^`;begin repeat read(c);if c=^`then begin write(copy(t+^j,2+9*pos(t+c,s+c)));s:=s+t;t:=''end;t:=t+c;until 1=0end.