#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[200009], b[200009], imos[100009], bit[100009]; vector<int> g[100009], gs[100009];
void add(int pos, int val) {
	for (int i = pos + 1; i <= 100000; i += i & (-i)) bit[i] += val;
}
int sum(int pos) {
	int ret = 0;
	for (int i = pos; i >= 1; i -= i & (-i)) ret += bit[i];
	return ret;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i]; a[i]--; b[i] -= 2;
		imos[a[i]]++;
		imos[b[i] + 1]--;
		g[b[i]].push_back(i);
		gs[a[i]].push_back(i);
	}
	for (int i = 0; i < 100000; i++) imos[i + 1] += imos[i];
	int rb = *max_element(imos, imos + 100000), ra = 0;
	for (int i = 0; i <= 100000; i++) {
		for (int j : gs[i]) add(i, 1);
		for (int j : g[i]) add(a[j], -1), add(i, 1);
		for (int j : g[i]) ra = max(ra, sum(i + 1) - sum(a[j]));
	}
	cout << ra << ' ' << rb << endl;
	return 0;
}