dconst n=5;
type man=packed array [1..n] of 0..9;
     por=packed array [1..2] of 0..9;
var mx, my, mz: man;
    px, py, pz: por;
    porx, pory, porz, i, v: integer; err:boolean;
begin
for i:=1 to n do read(mx[i]);
for i:=1 to 2 do read(px[i]); readln;
for i:=1 to n do read(my[i]);
for i:=1 to 2 do read(py[i]); readln;
porx:=10*px[1]+px[2]; pory:=10*py[1]+py[2];
if pory>porx then
 begin
 for i:=1 to n do begin mz[i]:=mx[i]; mx[i]:=my[i]; my[i]:=mz[i]; end;
 for i:=1 to 2 do begin pz[i]:=px[i]; px[i]:=py[i]; py[i]:=pz[i]; end;
 porx:=10*px[1]+px[2]; pory:=10*py[1]+py[2];
 end;
if (porx<(pory+n)) and (porx<>pory) then
 begin
 for i:=n downto (porx-pory+1) do my[i]:=my[i-(porx-pory)];
 for i:=1 to (porx-pory) do my[i]:=0;
 end;
if porx>=pory+n then for i:=1 to n do my[i]:=0;
{for i:=1 to n do write(my[i]); writeln;}
v:=0;
porz:=porx;
for i:=n downto 1 do
 begin
 mz[i]:=(mx[i]+my[i]+v) mod 10;
 v:=(mx[i]+my[i]+v) div 10;
end;
if (mx[1]+my[1]+v)>=10 then
 begin
 for i:=n downto 2 do mz[i]:=mz[i-1];
 porz:=porz+1;
 if porz=100 then err:=true else mz[1]:=1;
 end;
if not err then begin pz[1]:=porz div 10; pz[2]:=porz mod 10; end;
if err then writeln('oshibka')
       else begin
            for i:=1 to n do write(mz[i]); write(' '); write(pz[1], pz[2]);
            end;
readln;
end.