#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
void solve() {
  long long n;
  cin >> n;
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    mp[x]++, mp[y]--;
  }
  vector<pair<long long, long long> > v;
  for (auto i : mp) {
    v.push_back({i.first, i.second});
  }
  long long mx = v[0].second;
  for (long long i = 1; i < v.size(); i++)
    v[i].second += v[i - 1].second, mx = max(mx, v[i].second);
  for (long long i = 0; i < v.size(); i++) {
    if (v[i].second == mx) {
      cout << v[i].first << " " << v[i].second << "\n";
      return;
    }
  }
}
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  { solve(); }
  return 0;
}
