#include <bits/stdc++.h>
using namespace std;
struct as {
  long long t, c;
};
struct as a[1000001];
int main() {
  long long n, maxi, i, t, c, x, time = 0, prev;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t >> c;
    a[i].t = t;
    a[i].c = c;
  }
  x = a[0].c;
  maxi = x;
  prev = a[0].t;
  for (i = 1; i < n; i++) {
    if ((a[i].t < prev + 1 + x)) {
      x = x - (a[i].t - prev) + a[i].c;
      prev = a[i].t;
      if (x > maxi) maxi = x;
    } else {
      prev = a[i].t;
      x = a[i].c;
      if (x > maxi) maxi = x;
    }
  }
  cout << (prev + x) << " " << maxi;
  return 0;
}
