#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
using namespace std;
void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
}
long long A[500006];
long long B[500006];
long long C[500006];
vector<long long> V;
vector<long long> Ans;
vector<pair<long long, long long> > VP;
map<long long, long long> M;
vector<long long> prime;
bool mark[10000008];
long long N = 1e7;
void seive() {
  int limit = sqrt(N * 1.0) + 2;
  mark[1] = 1;
  for (int i = 4; i <= N; i += 2) mark[i] = 1;
  prime.push_back(2);
  for (int i = 3; i <= N; i += 2) {
    if (!mark[i]) {
      prime.push_back(i);
      if (i <= limit) {
        for (int j = i * i; j <= N; j += i * 2) mark[j] = 1;
      }
    }
  }
}
priority_queue<int> pq;
int main() {
  fastIO();
  long long a, b, c, d, n, m, k, l, p, q, r, t, x, y;
  long long cnt = 0, cntr = 0, sum = 0, ans = 1, check = 0;
  long long Max = 0, Max1 = -1e18 + 1, Min = 1LL << 63;
  string s, s1, s3, s4;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    VP.push_back(make_pair(a, b));
  }
  sort(VP.begin(), VP.end());
  for (int i = 0; i < n; i++) {
    a = VP[i].first;
    b = VP[i].second;
    pq.push(-1 * b);
    while (!pq.empty() && pq.top() >= -1 * a) {
      pq.pop();
    }
    c = pq.size();
    if (c > Max) {
      Max = c;
      ans = c;
      sum = a;
    }
  }
  cout << sum << " " << ans << endl;
  return 0;
}
