#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    const int LIM = 100010;
    vector<int> left(LIM), right(LIM), ims(LIM);
    vector<P> v(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ++ims[a];
        --ims[b];
        ++left[a];
        ++right[b];
        v[i] = P(a, b);
    }
    int ans1 = 0, ans2 = 0;
    for (int i = 1; i < LIM; ++i) {
        ims[i] += ims[i - 1];
        left[i] += left[i - 1];
        right[i] += right[i - 1];
        ans2 = max(ans2, ims[i]);
    }
    for (P& i : v) ans1 = max(ans1, left[i.second - 1] - right[i.first]);
    cout << ans1 << " " << ans2 << "\n";
    return 0;
}

