#include <bits/stdc++.h>
using namespace std;

const int START=0, END=1, NORMAL=1, EXCLUSIVE=-1;
int n, min_point=1e9, max_point=0;
vector<tuple<int, int, int>> points;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n;

    for(int i=0; i<n; i++)
    {
        int s, e;
        cin >> s >> e;

        min_point=min(min_point, s);
        max_point=max(max_point, e);
        points.push_back({s, NORMAL, START});
        points.push_back({e, NORMAL, END});
    }

    for(int i=min_point; i<=max_point; i++)
    {
        points.push_back({i, EXCLUSIVE, START});
        points.push_back({i+1, EXCLUSIVE, END});
    }

    sort(points.begin(), points.end());

    int curr=0, s=0, c=0;

    for(int i=0; i<points.size(); i++)
    {
        if(get<1>(points[i])==NORMAL)
        {
            if(get<2>(points[i])==START)
            {
                curr++;
            }
            else
            {
                curr--;
            }
        }
        else
        {
            if(get<2>(points[i])==END)
            {

                ////cout << get<0>(points[i]) << " " << curr << '\n';
                if(curr>c)
                {
                    c=curr;
                    s=1;
                }
                else if(curr==c)
                {
                    s++;
                }
            }
        }
    }

    cout << c << '\n';
    cout << s;
    return 0;
}
