var c1,c2:char; s:string; 
    l:integer;
begin

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