/**
6
7 9
5 6
1 4
7 9
1 8
2 6
**/

#include <bits/stdc++.h>

using namespace std;

const int COR_MAX = 1e7 + 1;
int br[COR_MAX];

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

    int n;
    int l = INT_MAX, r = 0;

    cin >> n;

    while (n--)
    {
        int x, y;

        cin >> x >> y;

        br[x]++;
        br[y]--;

        l = min(l, x);
        r = max(r, y);
    }

    int cnt = 0;
    int ans1 = 0, ans2 = 0;

    for (int i = l; i <= r; i++)
    {
        cnt += br[i];

        if (ans1 < cnt)
        {
            ans1 = cnt;
            ans2 = 0;
        }

        if (cnt == ans1)
        {
            ans2++;
        }
    }

    cout << ans1 << endl;
    cout << ans2 << endl;

    return 0;
}
