#include <bits/stdc++.h>
const int MOD = 1000000007;
const int MAX = 10000005;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  long long n;
  cin >> n;
  long long b, d;
  long long max = -1;
  long long y = 0;
  vector<pair<long long, long long> > vecx, vecy;
  for (long long i = 0; i < n; i++) {
    cin >> b >> d;
    vecx.push_back(make_pair(b, d));
    vecy.push_back(make_pair(d, b));
  }
  sort(vecx.begin(), vecx.end());
  sort(vecy.begin(), vecy.end());
  long long pointer1 = 0;
  long long pointer2 = 0;
  long long sum = 0;
  for (long long i = 0; i < 2 * vecx.size(); i++) {
    if (pointer1 == vecx.size() || pointer2 == vecx.size()) {
      goto ab;
    }
    if (vecx[pointer1].first < vecy[pointer2].first) {
      sum++;
      if (sum > max) {
        max = sum;
        y = vecx[pointer1].first;
      }
      pointer1++;
    } else if (vecx[pointer1].first > vecy[pointer2].first) {
      sum--;
      pointer2++;
    } else {
      sum--;
      pointer2++;
    }
  }
ab:;
  cout << y << " " << max << " ";
}
