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

int n, max_point=0, max_count=0, max_size=0;
int counter[10000001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n;

    for(int i=0; i<n; i++)
    {
        int s, e;
        cin >> s >> e;

        for(int j=s+1; j<=e; j++)
        {
            counter[j-1]++;

            if(max_count<counter[j-1])
            {
                max_count=counter[j-1];
                max_point=j-1;
                max_size=1;
            }
            else if(max_count==counter[j-1])
            {
                max_size++;
            }
        }
    }

    cout << max_count << '\n';
    cout << max_size;
    return 0;
}
