#include <bits/stdc++.h>
using namespace std;
bool ispow(long long n) { return (n & (n - 1)) == 0; }
const int mod = 1e9 + 7;
map<int, int> mp;
vector<pair<int, int> > v;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int b, d;
    cin >> b >> d;
    mp[b]++;
    mp[d]--;
  }
  for (auto u : mp) v.push_back(make_pair(u.first, u.second));
  int sz = v.size();
  for (int i = 1; i < sz; i++) v[i].second += v[i - 1].second;
  int pos = 0, ans = 0;
  for (int i = 0; i < sz; i++) {
    if (v[i].second > ans) {
      ans = v[i].second;
      pos = v[i].first;
    }
  }
  cout << pos << ' ' << ans << '\n';
  return 0;
}
