#include<iostream>
using namespace std;
const int MAX=10000001;
int m[MAX];
int main(){
cin.tie(0);
cout.tie(0);

int n,x,y,maxn=0,counter=0,mcounter=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>x>>y;
    for(int i=x;i<=y;i++){
        m[i]++;
    }
}
for(int i=0;i<MAX;i++){
    maxn=max(maxn,m[i]);

}
cout<<maxn;
for(int i=0;i<MAX;i++){
    if(m[i]==maxn){
        counter++;
    }
    else{
        if(mcounter<counter){mcounter=counter;}
        counter=0;
    }
}
if(mcounter<counter){mcounter=counter;}
cout<<'\n'<<mcounter;
return 0;
}
