program milkingcows;
var a:array[300..1000001] of boolean;
i,j,k,m,n,l,sc,c,sc2,tot1,tot2,nn:longint;
begin
readln(nn);
for i:=300 to 1000000 do a[i]:=false;
for i:=1 to nn do
begin
readln(m,n);
for j:=m to n do begin a[j]:=true; inc(c); end;
end;
i:=300;
while i<>n do
begin
repeat
inc(tot1);
inc(i);
if tot1>sc then sc:=tot1;
until a[i+1]=false; tot1:=0;
if i=n then break;
repeat
inc(tot2);
inc(i);
if tot2>sc2 then sc2:=tot2;
until a[i+1]=true; tot2:=0;
end;
writeln(sc,' ',sc2+1);
end.
var a:array[300..1000001] of boolean;
i,j,k,m,n,l,sc,c,sc2,tot1,tot2,nn:longint;
begin
readln(nn);
for i:=300 to 1000000 do a[i]:=false;
for i:=1 to nn do
begin
readln(m,n);
for j:=m to n do begin a[j]:=true; inc(c); end;
end;
i:=300;
while i<>n do
begin
repeat
inc(tot1);
inc(i);
if tot1>sc then sc:=tot1;
until a[i+1]=false; tot1:=0;
if i=n then break;
repeat
inc(tot2);
inc(i);
if tot2>sc2 then sc2:=tot2;
until a[i+1]=true; tot2:=0;
end;
writeln(sc,' ',sc2+1);
end.