#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<tuple>
#define llint long long int
#define lldo long double
#define fir first
#define sec second
#define pub push_back
#define mp make_pair
#define mt make_tuple
void maxeq(int &a,int b){if(a<b){a=b;}}
using namespace std;
int main(void){
	int n,i,ansA=0,ansB=0;cin>>n;
	vector<pair<int,int>> hito(n);
	vector<int>nin(100001);//?????°
	vector<int>sta(100001);//??????????´???????
	for(i=0;i<n;i++){
		cin>>hito[i].fir>>hito[i].sec;
		nin[hito[i].fir]++;
		sta[hito[i].fir]++;
		nin[hito[i].sec]--;
	}
	for(i=1;i<=100000;i++){nin[i]+=nin[i-1];sta[i]+=sta[i-1];}
	for(i=0;i<n;i++){
		maxeq(ansB,nin[hito[i].fir]);
		maxeq(ansA,nin[hito[i].fir]+sta[hito[i].sec-1]-sta[hito[i].fir]);
	}
	cout<<ansA<<" "<<ansB<<endl;
	return 0;
}