#include<iostream>

using namespace std;

void StartingAScenicRailroadService(const int board[], const int alight[], const int n) {
	static int geton[100001], getoff[100001], order[200000];
	int policy1 = 0, policy2 = 0;
	for (int s = 1;s <= 100000;s++)geton[s] = getoff[s] = 0;
	for (int i = 0;i < n;i++)++geton[board[i]], ++getoff[alight[i]];
	for (int s = 1;s < 100000;s++)geton[s + 1] += geton[s], getoff[s + 1] += getoff[s];
	for (int i = 0;i < n;i++)order[--geton[board[i]]] = i;
	for (int k = 0;k < n;k++) {
		int a = alight[order[k]], b = board[order[k]];
		if (geton[a] - getoff[b] > policy1)policy1 = geton[a] - getoff[b];
		if (geton[b + 1] - getoff[b] > policy2)policy2 = geton[b + 1] - getoff[b];
	}
	cout << policy1 << ' ' << policy2 << endl;
}

int main() {
	static int board[200000], alight[200000];
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> board[i] >> alight[i];
	StartingAScenicRailroadService(board, alight, n);
}
