#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int Delta[10000000];
int Act[10000000];

int main()
{
    vector <pair <int, int>> R;
    int MaxN = -100;

    int N, T1, T2;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> T1 >> T2;
        R.push_back({T1 - 1, 1});
        R.push_back({T2 - 1, -1});
        MaxN = max(MaxN, T1);
        MaxN = max(MaxN, T2);
    }

    sort (R.begin(), R.end());

    int MaxQ = -100;
    int CQ = 0;

    for (const auto &t : R)
    {
        CQ += t.second;
        MaxQ = max(MaxQ, CQ);
    }

    cout << MaxQ << endl;

    for (const auto &t : R)
    {
        Delta[t.first] += t.second;
    }

    Act[0] = Delta[0];

    for (int i = 1; i < MaxN; i++)
    {
        Act[i] = Act[i - 1] + Delta[i];
    }

    int A2 = 0;

    for (int i = 0; i < MaxN; i++)
    {
        A2 += Act[i] == MaxQ;
    }

    cout << A2 << endl;
}
