#include <bits/stdc++.h>
using namespace std;
int n, a[10000001], x, y, 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;
        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;
    return 0;
}
