#include<bits/stdc++.h>
using namespace std;
vector< pair<char,long long> > v[999990];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n ;
    cin>>n;
    int x, y, endM = 0;
    for(int i = 1; i <= n ; i++){
        cin>>x>>y;
        v[x].push_back({'o',i});
        v[y].push_back({'c',i});
        endM = max(endM,y);
    }
    long long Op = 0,prev = 0;;
    long long mxS = 0 , d = 0;
    for(long long i = 1 ; i < endM ; i++){
        for(int j = 0; j < v[i].size(); j++){
            if(v[i][j].first == 'o'){
                Op++;
            }else{
                Op--;
            }
        }
        if(Op == prev && mxS <min(Op,prev)){
            mxS = min(Op,prev);
            d = 1;
        }
        if(Op == mxS) d++;
        prev = Op;
    }
    cout<<mxS<<endl<<d;
    return 0;

}
