#include <bits/stdc++.h>
using namespace std;
int _;
bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  _ = 1;
  while (_--) {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i].first >> a[i].second;
    }
    vector<pair<int, int>> start_time = a;
    vector<pair<int, int>> end_time = a;
    sort(start_time.begin(), start_time.end());
    sort(end_time.begin(), end_time.end(), comp);
    int cnt = 1, place = start_time[0].first;
    int ans = 1;
    int index = 0;
    for (int i = 1; i < n; i++) {
      cnt += 1;
      while (index < n && end_time[index].second <= start_time[i].first) {
        index++;
        cnt--;
      }
      if (ans < cnt) {
        ans = cnt;
        place = start_time[i].first;
      }
    }
    cout << place << " " << ans << '\n';
  }
  return 0;
}
