#include <iostream>

/*

6
1 2
3 4
5 6
7 8
9 10
11 12
-----
1 12

6
7 9
5 6
1 4
7 9
1 8
2 6
------
1 8

6
1 2
2 3
3 4
4 5
5 6
6 7


*/

using namespace std;

int main() {
    int n;

    cin >> n;

    int x[n], y[n];
    int start, finish;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        if (i == 0) {
            start = x[0];
            finish = y[0];
        } else {
            start = min(x[i], start);
            finish = max(y[i], finish);
        }
    }

    int field[finish - start];
    for (int i = 0; i < finish - start; i++) {
        field[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = x[i]; j < y[i]; j++) {
            field[j - 1]++;
        }
    }

    int max_cover = field[0], br = 0;
    for (int i = 0; i < finish - start; i++) {
        if (field[i] == max_cover) {
            br++;
        }
        max_cover = max(field[i], max_cover);
    }

    cout << max_cover << endl;

    cout << br << endl;

    return 0;
}
