#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int n;
int a[SIZE], b[SIZE];

int solve1(){
  int right[SIZE] = {};
  int left[SIZE] = {};

  for(int i=0;i<n;i++){
    right[b[i]]++;
    left[a[i]]++;
  }

  for(int i=0;i<SIZE/2;i++){
    right[i+1] += right[i];
    left[SIZE/2 - i] += left[SIZE/2 - i + 1];
  }

  int ans = 0;
  
  for(int i=0;i<n;i++){
    ans = max(ans, n - right[a[i]] - left[b[i]]);
  }

  return ans;
}


int solve2(){
  int sum[SIZE] = {};
  int ans = 0;
  
  for(int i=0;i<n;i++){
    sum[a[i]]++;
    sum[b[i]]--;
  }

  for(int i=0;i<SIZE/2;i++){
    sum[i+1] += sum[i];
    ans = max(sum[i], ans);
  }

  return ans;
}


int main(){

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d%d",a+i, b+i);
  }

  printf("%d %d\n",solve1(), solve2());
  
  return 0;
}

