#include<iostream>
using namespace std;
int n, mostIntersecting = -1, intersecting = 0;
long long line[10000000], mostFartherOut = -1;
void cleanLine(){
    for(int i = 0; i < 10000000; ++i){
        line[i] = 0;
    }
}
void addSegment(int a, int b){
    for(int i = a; i < b; ++i){
        line[i]++;
        if(line[i] == mostIntersecting)
            intersecting++;
        if(line[i] > mostIntersecting){
            mostIntersecting = line[i];
            intersecting = 1;
        }
    }
}
int main(){
    cleanLine();
    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;
}
