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

int n, min_point=1e9, max_point=0;
pair<int, int> points[50001];

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

    cin >> n;

    for(int i=0; i<n; i++)
    {
        cin >> points[i].first >> points[i].second;
        min_point=min(min_point, points[i].first);
        max_point=max(max_point, points[i].second);
    }

    sort(points, points+n);

    int s=0, c=0;

    for(int i=min_point; i<=max_point; i++)
    {
        int curr=0;

        for(int j=0; j<n; j++)
        {
            if(points[j].first>i)
            {
                break;
            }

            if(points[j].first<=i && points[j].second>=i+1)
            {
                curr++;
            }
        }

        if(curr>c)
        {
            c=curr;
            s=1;
        }
        else if(curr==c)
        {
            s++;
        }
    }

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