{
TASK:phrope
LANG:PASCAL
}
var a,b,x,y:string[51];
    s:string;
    i:integer;

function tcet(num:string):boolean;
var t:string;
begin
     t:=num[length(num)];
     if (t='0') or (t='2') or(t='4') or (t='6') or (t='8')
        then tcet:=true
        else tcet:=false;
end;

function compare(aa,bb:string):boolean;
begin
     if length(aa)=length(bb)
        then if aa>bb
             then compare:=true
             else compare:=false
        else if length(aa)>length(bb)
             then compare:=true
             else compare:=false;
end;

function del2(num:string):string;
var len,i:byte;
    tt,t,c,ost:integer;
    res,r:string[51];
begin
     res:=''; ost:=0; r:='';
     i:=1; len:=length(num);
     while i<=len do begin
           val(num[i],t,c);
           t:=t+ost;
           if (t<2) and (i<len)
              then begin
                   inc(i);
                   val(num[i],tt,c);
                   t:=t*10 + tt;
              end;
           str((t div 2),r);
           res:=res+r;
           ost:=10*(t mod 2);
           inc(i);
     end;
     del2:=res;
end;

function umn2(num:string):string;
var res,r:string;
    pr,i,len,t,c,p:integer;

begin
     res:='';i:=length(num); pr:=0;
     while i>=1 do begin
           val(num[i],t,c);
           p:=t*2+pr;
           str((p mod 10),r);
           res:=r+res;
           pr:=p div 10;
           dec(i);
     end;
     if pr>0
        then begin
             str(pr,r);
             res:=r+res;
        end;
     umn2:=res;
end;

begin
     readln(s);
     a:=copy(s,1,(pos(' ',s)-1));
     delete(s,1,pos(' ',s));
     b:=s;
     if (a=b) and (length(a)=length(b))
        then writeln('0 0')
        else begin
             if (compare(a,b)=true)
                then begin
                     x:=del2(a);
                     if (((length(x)=length(b))and(x=b))
                     or (compare(x,b)=false)) and (tcet(a)=true)
                        then writeln(a,' ',x)
                        else if (((length(x)=length(b))and(x>b))
                        or (compare(x,b)=true))
                           then begin
                                x:=umn2(b);
                                writeln(x,' ',b);
                           end
                           else writeln('0 0');
                end
                else begin
                     y:=del2(b);
                     if (((length(a)=length(y))and(a=y))
                     or (compare(a,y)=true)) and (tcet(b)=true)
                        then writeln(y,' ',b)
                        else if (((length(a)=length(y))and(a<y))
                        or (compare(a,y)=false))
                           then begin
                                y:=umn2(a);
                                writeln(a,' ',y);
                           end
                           else writeln('0 0');
                end;
        end;

end.