#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;
        }
    }
}
long long amountIntersecting(){
    long long counter = 0;
    for(int i = 0; i < mostFartherOut; ++i){
        if(line[i] == mostIntersecting){
            counter++;
        }
    }
    return counter;
}
int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        int buff1, buff2;
        cin >> buff1 >> buff2;
        if(buff2 > mostFartherOut)
            mostFartherOut = buff2;
        addSegment(buff1, buff2);
    }
    cout << mostIntersecting << endl << intersecting;
    return 0;
}
