#include <bits/stdc++.h>
using namespace std;
const int imax = INT32_MAX;
const int imin = INT32_MIN;
const long long int inf = 1e18;
const long long int MOD = 1e9 + 7;
const long long int range = 2 * 1e6;
std::vector<vector<int>> g;
template <class T>
T cal(T n) {
  return (n * 1ll * (n + 1));
}
template <class T>
T mx(T begin, T end) {
  return max_element(begin, end);
}
template <class T>
T mn(T begin, T end) {
  return min_element(begin, end);
}
template <class T>
void getUnique(vector<T>& nums) {
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
}
template <class T>
void print(vector<T> nums) {
  for (T i : nums) {
    cout << i;
    cout << "\n";
  }
}
template <class T>
void read(vector<T>& nums) {
  for (T& i : nums) cin >> i;
}
template <class T>
void freq(map<T, T>& umap, vector<T> nums) {
  for (T ele : nums) umap[ele]++;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int>> nums;
    for (int i = 0; i < n; ++i) {
      int l, r;
      cin >> l >> r;
      nums.push_back({l, 1});
      nums.push_back({r, -1});
    }
    sort(nums.begin(), nums.end());
    int yr, ans = 0, curr = 0;
    for (auto it : nums) {
      curr += it[1];
      if (ans < curr) {
        ans = curr;
        yr = it[0];
      }
    }
    cout << yr << " " << ans;
  }
  return 0;
}
