#include <bits/stdc++.h>
using namespace std;
void FASTIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void print(vector<long long> v) {
  for (auto x : v) {
    cout << x << ' ';
  }
  cout << endl;
}
bool sortbySec(pair<long long, long long> &a, pair<long long, long long> &b) {
  return (a.second > b.second);
}
long long t, n;
void solve() {
  cin >> n;
  vector<pair<long long, long long>> v;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, 1));
    v.push_back(make_pair(y, -1));
  }
  sort(v.begin(), v.end());
  long long mx = INT_MIN, val = -1;
  long long count = 0;
  for (auto &xx : v) {
    count += xx.second;
    if (count > mx) {
      mx = count;
      val = xx.first;
    }
  }
  cout << val << " " << mx << "\n";
}
int main() {
  FASTIO();
  solve();
}
