#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
long long sw[10000001], curr[10000001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin>>n;
    for(long long i=0; i<n; i++)
    {
        long long a, b;
        cin>>a>>b;
        sw[a]++;
        sw[b]--;
    }
    for(long long i=1; i<=1e7; i++)
    {
        curr[i]=curr[i-1]+sw[i];
    }
    long long mx=0, ans=0;
    for(long long i=1; i<=1e7; i++)
    {
        //if(i<=9) cout<<curr[i]<<endl;
        if(curr[i]==mx)
        {
            ans++;
        }
        else
        {
            if(curr[i]>mx)
            {
                mx=curr[i];
                ans=1;
            }
        }
    }
    cout<<mx<<endl<<ans;
    return 0;
}
