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