#include <bits/stdc++.h>
using namespace std;
long long int max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
int main() {
  long long mx = 0, t1 = 0, t = 0, a = 0, now = 0;
  long long n;
  cin >> n;
  cin >> t >> a;
  long long f = t, e = t;
  now = a;
  t1 = t;
  mx = now;
  for (int i = 1; i < n; i++) {
    cin >> t >> a;
    now -= (t - t1);
    now = max(now, 0);
    now += a;
    t1 = t;
    mx = max(mx, now);
    e = t;
  }
  cout << e + now << " " << mx;
  return 0;
}
