#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
vector <pair<int, int>> sub;
long long st = 100000000, en = 0;
int main (){
    cin>>N;
    for(int i = 0; i < N; i ++){
        int a, b;
        cin>>a>>b;
        sub.push_back({a, 1});
        sub.push_back({b, -1});
        if(a < st){
            st = a;
        }
        if(en < b){
            en = b;
        }
    }
    int br = 0, maxbr = 0;
    sort(sub.begin(), sub.end());
    for(int i = 0; i < sub.size(); i ++){
        br += sub[i].second;
        if(br > maxbr){
            maxbr = br;
        }
    }
    br = 0;
    int tekbr = 0;
    int x = 0;
    for(int i = st; i <= en; i++){
        ///cout<<br<<endl;
        ///cout<<sub[x].first<<" "<<i<<endl;
        while(x < sub.size() && sub[x].first == i){
            ///cout<<"tuk "<<x<<endl;
            br+=sub[x].second;
            x++;
        }
        if(br == maxbr){
            tekbr++;
        }
    }
    cout<<maxbr<<endl<<tekbr;
    return 0;
}

