                                        #include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                                #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                 
                                        using namespace std;

int par[500100],ranks[500100],kosuu[500100];     

void shoki(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ranks[i]=0;
		kosuu[i]=1;
	}
}

int root(int x){
	return par[x]==x ? x : par[x]=root(par[x]);
}

bool same(int x,int y){
return root(x)==root(y);
}

void unite(int x,int y){
 x=root(x);
 y=root(y);
	int xx=kosuu[x],yy=kosuu[y];
 if(x==y) return;
	if(ranks[x]<ranks[y]){
		par[x]=y;
		kosuu[y]=yy+xx;
	}
 else {
	par[y]=x;
	if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1;
 	kosuu[x]=yy+xx;
 }
	return;
}

int gcd(int a1,int a2){
	if(a1<a2) return gcd(a2,a1);
	if(a2==1) return 1;
	if(a1%a2==0) return a2;
	return gcd(a2,a1%a2);
}


int rui2(int e,int r){
	if(r==0) return 1;
	if(r==1) return e%inf;
	if(r%2==1) return (e*rui2(e,r-1))%inf;
	int w=rui2(e,r/2)%inf;
	return (w*w)%inf;
}

int n;
int a[200030];
int b[200030];
int hajime[200030]={0},owari[200030]={0};
int imos[200030]={0};

int solve1(){
	for(int i=0;i<n;i++)hajime[a[i]]++,owari[b[i]]++;
	for(int i=1;i<=200000;i++)owari[i]+=owari[i-1];
	for(int i=200000;i>=0;i--)hajime[i]+=hajime[i+1];
	
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,n-owari[a[i]]-hajime[b[i]]);
	}
	return ans;
}
int solve2(){
	int ans=0;
	for(int i=0;i<n;i++)imos[a[i]]++,imos[b[i]]--;
	
	for(int i=1;i<=200000;i++){
		imos[i]+=imos[i-1];
		ans=max(imos[i],ans);
	}
	return ans;
//	cout<<ans<<endl;
}

            signed main(){
   cin>>n;
            	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
            	
            	cout<<solve1()<<" "<<solve2()<<endl;
            	return 0;
            }
             