#include<iostream>
#include<algorithm>
using namespace std;
const int MAXM = 50010;
pair <int, int> subitiq[MAXM];
int main (){
    int st = 10000000, en = 0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int N;
    cin>>N;
    int in = 0;
    for(int i = 0; i < N; i++){
        int a, b;
        cin>>a>>b;
        subitiq[in].first = a;
        subitiq[in].second = 1;
        in++;
        subitiq[in].first = b;
        subitiq[in].second = -1;
        in++;
        if(st > a){
            st = a;
        }
        if( en < b){
            en = b;
        }
    }
    int br = 0, maxbr = 0;
    sort(subitiq, subitiq + in);
    for(int i = 0; i < in; i ++){
        br += subitiq[i].second;
        if(br > maxbr){
            maxbr = br;
        }
    }
    br = 0;
    int tekbr = 0, maxdul = 0;
    int x = 0;
    for(int i = st; i <= en; i++){
        ///cout<<br<<endl;
        ///cout<<subitiq[x].first<<" "<<i<<endl;
        while(x < in && subitiq[x].first == i){
            ///cout<<"tuk "<<x<<endl;
            br+=subitiq[x].second;
            x++;
        }
        if(br == maxbr){
            tekbr++;
        }
    }
    cout<<maxbr<<endl<<tekbr;
    return 0;
}
/**
6
7 9
5 6
1 4
7 9
1 8
2 6
*/
