#include<bits/stdc++.h>
using namespace std;
pair<int, int> point[50001];
int arr[50001];
int n,maxi=0, mini=10000000, br;
int temp(int arr[], int low, int high)
{
    int pivot = arr[high];
    int i = (low- 1);

    for (int j = low; j <= high - 1; j++)
    {

        if (arr[j] < pivot)
        {
            i++;
            swap(arr[i], arr[j]);
        }
    }
    swap(arr[i + 1], arr[high]);
    return (i + 1);
}

void quickSort(int arr[], int low, int high)
{
    if (low < high)
    {

        int pi = temp(arr, low, high);

        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>point[i].first>>point[i].second;
        mini=min(mini,point[i].first);
        maxi=max(maxi,point[i].second);
    }
    //sort(point,point+n);
    for(int i=mini; i<=maxi; i++)
    {
        for(int j=0; j<n and point[j].first<=i; j++)
        {
            if(point[j].second>i) br++;
        }
        arr[i-mini]=br;
        br=0;
    }
    quickSort(arr, 0, maxi-mini);
    cout<<arr[maxi-mini]<<"\n";
    int i;
    for(i=maxi-mini; i>=0; i--)
    {
        if(arr[i]!=arr[i-1]) break;
    }
    cout<<maxi-i<<"\n";
    return 0;
}
