#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll maxn=10e7+1;
ll n, a[maxn], x, y, ng, ans;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>x>>y;
        ng=max(y, ng);
        for (int j=x; j<y; j++)
        {
            a[j]++;
        }
    }
    sort(a + 1, a+ng);
    cout<<a[ng - 1]<<"\n";
    int i=ng - 1;
    while (i>=1 && a[i]==a[ng-1])
    {
        ans++;
        i--;
    }
    cout<<ans<<"\n";
    return 0;
}
