var c1,c2:char; s:string; m,l,i:integer; begin while true do begin readln(s); if s = '0 0 0' then break; l:=length(s); c2:=s[l]; c1:=s[l-2]; m:=length(s)-4; If (s[1]=c1) and (c2='0') then for i:=2 to m do write(s[i]) else for i:=1 to m do begin If s[i]=c1 then s[i]:=c2; write(s[i]); end; writeln; end; end.