#include<bits/stdc++.h>
using namespace std;

vector<int> haha(10000001);

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,a,b,p = 0,br = 0,big = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        haha[a]++;
        haha[b]--;
    }
    for(int i = 0; i <= 10000000; i++) {
        p+=haha[i];
        if(p == big) {
            br++;
        }
        else if(p > big) {
            br = 1;
            big = p;;
        }
    }
    cout << big << "\n" << br;
    return 0;
}
