#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
signed main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  long long a, b;
  long long ma = 0, curr = 0, first = 1;
  for (long long i = 0; i < n; i++) {
    cin >> a >> b;
    v.push_back({a, 1});
    v.push_back({b, -1});
  }
  sort(v.begin(), v.end());
  for (long long i = 0; i < v.size(); i++) {
    curr += v[i].second;
    if (curr > ma) ma = curr, first = v[i].first;
  }
  cout << first << " " << ma << endl;
}
