#include<bits/stdc++.h>
using namespace std;
vector< pair<char,int> > v[1000007];
int op[10000007];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int 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);
    }
    int Op = 0;
    int mxS = 0 , d = 0;
    for(int i = 1 ; i < endM ; i++){
        for(int j = 0; j < v[i].size(); j++){
            if(v[i][j].first == 'o'){
                Op++;
            }else{
                Op--;
            }
        }
        op[i] = Op;
        if(Op == op[i-1] && mxS <min(Op,op[i-1])){
            mxS = min(Op,op[i-1]);
            d = 1;
        }
        if(Op == mxS) d++;

    }
    cout<<mxS<<endl<<d;
    return 0;

}
