#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, ngs, br;
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]++;
            if (a[j]==ngs)
            {
                br++;
            }
            if (a[j]>ngs)
            {
                ngs=a[j];
                br=1;
            }
        }
    }
    cout<<ngs<<"\n"<<br<<"\n";
    return 0;
}
