#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  map<long long, long long> m1;
  while (n--) {
    long long b, d;
    cin >> b >> d;
    m1[b]++, m1[d]--;
  }
  long long max = 0, p, s = 0;
  for (auto itr = m1.begin(); itr != m1.end(); itr++) {
    s = s + itr->second;
    if (s > max) {
      max = s;
      p = itr->first;
    }
  }
  cout << p << ' ' << max << endl;
}
