#include<iostream>
using namespace std;
int n, mostIntersecting = -1, intersecting = 0, mostFartherOut = -1;
long long line[10000000];
void addSegment(int a, int b){
    for(int i = a; i < b; ++i){
        line[i]++;
       /* if(line[i] == mostIntersecting){
            intersecting++;
        }/*else if(line[i] > mostIntersecting){
            mostIntersecting = line[i];
            intersecting = 1;
        }*/
    }
}
int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        if(b > mostFartherOut){
            mostFartherOut = b;
        }
        addSegment(a, b);
    }
    cout << mostIntersecting << endl << intersecting;
    return 0;
}
