{
TASK:phrope
LANG:PASCAL
}

var
a,b,d : array [ 1 .. 51 ] of byte;
c,x,y,i,z : integer;
ch : char;

function wh:byte;
var
c : array [ 1 .. 50 ] of byte;
i,pr : integer;
p : boolean;
begin
if x<y-1 then begin wh:=1; exit; end;
if y<x-1 then begin wh:=3; exit; end;
if x>y then p:=false else if x<y then p:=true;
if x=y then for i:=x to 50 do if a[i]>b[i] then begin p:=true; break; end
  else if a[i]<b[i] then begin p:=false; break; end;
if (i=50) and (a[i]=b[i]) then begin wh:=0; exit; end;
pr:=0;
for i:=1 to 51 do c[i]:=0;
if p then for i:=50 downto y-1 do begin c[i]:=(b[i]*2+pr) mod 10; pr:=(b[i]*2+pr) div 10; end;
if not p then for i:=50 downto x-1 do begin c[i]:=(a[i]*2+pr) mod 10; pr:=(a[i]*2+pr) div 10 end;
if p then for i:=x-1 to 50 do
    if a[i]>c[i] then begin wh:=1; exit; end else
    if a[i]<c[i] then begin wh:=2; exit; end;
if i=50 then begin wh:=1; exit; end;
if not p then for i:=y-1 to 50 do
    if b[i]>c[i] then begin wh:=3; exit; end else
    if b[i]<c[i] then begin wh:=4; exit; end;
if i=50 then begin wh:=1; exit; end;
end;

procedure del(bu : char);
var
i: integer;
begin
if bu='a' then for i:=x to 50 do begin d[i]:=a[i] div 2; d[i+1]:=d[i+1]+(a[i] mod 2)*10; end;
if bu='b' then for i:=y to 50 do begin d[i]:=b[i] div 2; d[i+1]:=d[i+1]+(b[i] mod 2)*10; end;
end;

procedure ao;
var
i:integer;
begin
for i:=x to 50 do write(a[i]);
end;

procedure bo;
var
i:integer;
begin
for i:=y to 50 do write(b[i]);
end;

{procedure min(r:char);
var
i,v: integer;
begin
if r='a' then for i:=50 to x do if a[i]>b[i] then d[i]:=a[i]-b[i] else
begin
v:=1;
repeat
if a[i-v]<>0 then begin dec(a[i-1]); d[i]:=a[i]+10-b[i]; end
else begin a[i-v]=9
}
begin
x:=50;
repeat
read(ch);
if (ch>='0') and (ch<='9') then begin val(ch,a[x],c); dec(x); end;
until ch=' ';
inc(x);
y:=50;
repeat
read(ch);
if (ch>='0') and (ch<='9') then begin val(ch,b[y],c); dec(y); end;
until (ch<'0') or (ch>'9');
inc(y);
for i:=x to 49 do begin z:=a[i]; a[i]:=a[50-i+x]; a[50-i+x]:=z; end;
for i:=y to 49 do begin z:=b[i]; b[i]:=b[50-i+y]; b[50-i+y]:=z; end;

{writeln;
for i:=50 downto x do write(a[i]);
writeln;
for i:=50 downto y do write(b[i]);
readln;}
i:=wh;
case wh of
0 : if a[50] mod 2=0 then begin ao; del('a'); write(' '); for i:=x to 50 do if (i=x) and (d[i]=0) then else write(d[i]); end
else write('0 0');
1 : begin del('b'); for i:=y to 50 do if (i=y) and (d[i]=0) then else write(d[i]); write(' '); bo; exit; end;
2,4 : begin
 if a[50] mod 2=0 then begin ao; del('a'); write(' '); for i:=x to 50 do if (i=x) and (d[i]=0) then else write(d[i]); end;
 if b[50] mod 2=0 then begin del('b'); for i:=y to 50 do if (i=y) and (d[i]=0) then else write(d[i]); write(' '); bo; end;
end;
3 : begin ao; write(' '); del('a'); for i:=x to 50 do if (i=x) and (d[i]=0) then else write(d[i]); exit; end;
end;
readln;
end.

