#include<iostream>
using namespace std;

int x[10000000];
int y[10000000];

int main ()
{
    long long n, m=0;
    cin >> n;
    for (long long i=0; i<n; i++)
    {
        cin >> x[i] >> y[i];
        if (y[i]>m)
        {
            m=y[i];
        }
    }
    long long k, br=0, br1=1, br2=0;
    for (long long i=0; i<=m; i++)
    {
        k=i+1;
        br=0;
        for (long long j=0; j<n; j++)
        {
            if (x[j]<=i && y[j]>=k)
                br++;
        }
        if (br>br1)
            br1=br;
    }
    for (long long i=0; i<=m; i++)
    {
        k=i+1;
        br=0;
        for (long long j=0; j<n; j++)
        {
            if (x[j]<=i && y[j]>=k)
                br++;
        }
        if (br==br1)
            br2++;
    }
    cout << br1 << endl << br2 << endl;
    return 0;
}
