{
TASK:phrope
LANG:PASCAL
}
type rezult=Array[0..60] of byte;
var s,s1,s2,t:String;
    a,b,c1,c2:rezult;
    i,j:Longint;
    code:Integer;
    t1,t2:QWord;
Function xdiv2(x:rezult):rezult;
var tmp,cpy:rezult;
    i:byte;
Begin
 For i:=1 to 60 do tmp[i]:=0;
  cpy:=x;
 For i:=60 downto 1 do
 Begin
   if cpy[i]div 2>0 then tmp[i]:=cpy[i] div 2
                    else tmp[i]:=0;
   tmp[i-1]:=tmp[i-1]+(cpy[i]mod 2)*10;
 End;
  xdiv2:=tmp;
End;
Function xmul2(x:rezult):rezult;
var tmp,cpy:rezult;
    i,l:byte;
Begin
 For i:=1 to 60 do tmp[i]:=0;
 For i:=60 downto 1 do
  if x[i]<>0 then
  Begin
    l:=i;
    break;
  End;
  cpy:=x;
 For i:=1 to l do
 Begin
   tmp[i]:=(cpy[i] * 2)mod 10;
   tmp[i+1]:=tmp[i+1]+(cpy[i] * 2)div 10;
 End;
  xmul2:=tmp;
End;
Function reztostr(x:rezult):String;
var i,l:byte;
    s:String;
Begin
  s:='';
 For i:=60 downto 1 do
  if x[i]<>0 then
  Begin
    l:=i;
    break;
  End;
 For i:=l downto 1 do
  s:=s+chr(x[i]+48);
  reztostr:=s;
End;
Function xminusy(x,y:rezult):rezult;
var tmp,cpy:rezult;
    i,j,l:byte;
Begin
 For i:=1 to 60 do tmp[i]:=0;
 For i:=60 downto 1 do
  if x[i]<>0 then
  Begin
    l:=i;
    break;
  End;
  cpy:=x;
 For i:=1 to l do
  if cpy[i]-y[i]>=0 then tmp[i]:=cpy[i]-y[i]
  else
  Begin
   For j:=i to l do
    if cpy[j]=0 then cpy[j]:=9
    else
    if j<>i then
    Begin
      cpy[j]:=cpy[j]-1;
      Break;
    End;
    tmp[i]:=cpy[i]+10-y[i];
  End;
End;
Begin
  ReadLn(s);
  s1:=copy(s,1,pos(' ',s)-1);
  s2:=copy(s,pos(' ',s)+1,length(s)-pos(' ',s));
 For i:=length(s1) downto 1 do
  val(s1[i],a[length(s1)-i+1],code);
 For i:=length(s2) downto 1 do
  val(s2[i],b[length(s2)-i+1],code);
  c1[1]:=1;
{ if (reztostr(xmul2(xminusy(a,c1)))=reztostr(xminusy(b,c1))) then
 Begin
   WriteLn(reztostr(xminusy(a,c1)),' ',reztostr(xminusy(b,c1)));
   Exit;
 End;}
    val(s1,t1,code);
    val(s2,t2,code);
   if code=0 then
   Begin
    if ((t1-1)*2)=(t2-1)then
    Begin
      WriteLn(t1-1,' ',t2-1);
      Exit;
    End;
    if ((t1-1))=((t2-1)*2)then
    Begin
      WriteLn(t1-1,' ',t2-1);
      Exit;
    End;
   End;
 if (a[1]mod 2=1)and(b[1]mod 2=1)and(s1<>'1')and(s2<>'1')then
 Begin
   WriteLn('0 0');
   Exit;
 End;
 if (a[1]mod 2=0)and(s1=s2)then
 Begin
   WriteLn(reztostr(xdiv2(a)),' ',s2);
   Exit;
 End;
 if (a[1]mod 2=0)and(s2>=reztostr(xdiv2(a)))and(s1>s2)then
 Begin
   WriteLn(s1,' ',reztostr(xdiv2(a)));
   Exit;
 End;
 if (b[1]mod 2=0)and(s1>=reztostr(xdiv2(b)))and(s1<s2)then
 Begin
   WriteLn(reztostr(xdiv2(b)),' ',s2);
   Exit;
 End;
 if (s1='1')and(s2>s1)then
 Begin
   WriteLn('1 2');
   Exit;
 End;
 if (s2='1')and(s1>s2)then
 Begin
   WriteLn('2 1');
   Exit;
 End;
 if (s2>=reztostr(xmul2(a)))then
 Begin
   WriteLn(s1,' ',reztostr(xmul2(a)));
   Exit;
 End;
 if (s1>=reztostr(xmul2(b)))then
 Begin
   WriteLn(reztostr(xmul2(b)),' ',s2);
   Exit;
 End;
End.
