#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll maxn=10e7+1;
vector<pair<ll, ll>> v;
ll n, a[maxn], x, y, ng, ans;
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;
        v.push_back({x, y});
        ng=max(y, ng);
    }
    for (int i=1; i<ng; i++)
    {
        for (int j=0; j<v.size(); j++)
        {
            if (i>=v[j].first && i<v[j].second)
            {
                a[i]++;
            }
        }
        //cout<<i<<" "<<a[i]<<"\n";
    }
    //cout<<"\n";
    sort(a, a+ng);
    cout<<a[ng - 1]<<"\n";
    int i=ng - 1;
    while (i>=1 && a[i]==a[ng -1])
    {
        ans++;
        i--;
    }
    cout<<ans<<"\n";
    return 0;
}
