#include <iostream>
#include <algorithm>
using namespace std;

int a[10000000];

int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, max_y = 0, max_cover = 0, max_cover_num = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        max_y = max(max_y, y);
        for (int q = x; q < y; q++) {
            a[q]++;
        }
    }

    for (int i = 0; i < max_y; i++) {
        if (a[i] == max_cover) {
            max_cover_num++;
        }

        if (a[i] > max_cover) {
            max_cover = a[i];
            max_cover_num = 1;
        }

    }
    cout << max_cover << "\n" << max_cover_num;
}
