#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> v(1000001);
  for (long long i = 1; i <= n; ++i) {
    long long t;
    cin >> t;
    long long c;
    cin >> c;
    v[t] += c;
  }
  long long q = 0;
  long long qmax = 0;
  long long index = 1;
  for (long long i = 1; i <= 1000000; ++i) {
    if (q != 0) {
      q -= 1;
      index = i;
    }
    if (v[i] != 0) {
      q += v[i];
      if (q > qmax) {
        qmax = q;
      }
      index = i;
    }
  }
  while (q != 0) {
    q -= 1;
    index += 1;
  }
  cout << index << " " << qmax;
  return 0;
}
