#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int off[10000010] = {0};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<pii> v;
    int first = 10000000;
    int last = 0;
    for(int i = 0; i < n; i++){
        pii tmp;
        cin >> tmp.first >> tmp.second;
        off[tmp.first]++;
        off[tmp.second]--;
        if(tmp.first < first){
            first = tmp.first;
        }
        if(tmp.second > last){
            last = tmp.second;
        }
    }

    int cnt = 0;
    int depth = 0;
    int pdepth = -1;
    int mxDepth = 0;
    for(int i = first; i <= last; i++){
        depth += off[i];
        if(depth > mxDepth){
            mxDepth = depth;
            cnt = 0;
        }
        if(depth == mxDepth){
            cnt++;
        }
    }

    cout << mxDepth << ' ' << cnt << '\n';

    return 0;
}
