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

const int maxn = 1e5 + 5;
int a[maxn];
int numl[maxn], numr[maxn];

struct ed{
	int l, r;
}eds[2 * maxn];

int main()
{
	int n;
	int rd = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) 
	{
		scanf("%d%d", &eds[i].l ,&eds[i].r);
		a[eds[i].l]++;
		a[eds[i].r]--;
		numl[eds[i].l]++;
		numr[eds[i].r]++;
		rd = max(rd, eds[i].r);
	}
	int ma1 = 0, num = 0, ma2 = 0;
	for(int i = 1; i <= rd; i++)
	{
		a[i] += a[i - 1];
		ma2 = max(ma2, a[i]);
		numl[i] += numl[i - 1];
		numr[i] += numr[i - 1];
	}
	for(int i = 1; i <= n; i++)
	{
		int ans = numl[eds[i].r - 1] - numr[eds[i].l];
		ma1 = max(ma1, ans);
	}
	printf("%d %d\n", ma1, ma2);
	return 0;
}
