#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int maxn=10e7+1;
int n, a[maxn], x, y, ng, nm=maxn, 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);
        nm=min(x, nm);
        for (int j=x; j<y; j++)
        {
            a[j]++;
        }
    }
    sort(a + nm - 1, a+ng);
    cout<<a[ng - 1]<<"\n";
    int i=ng - 1;
    while (i>=nm && a[i]==a[ng-1])
    {
        ans++;
        i--;
    }
    cout<<ans<<"\n";
    return 0;
}
