#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c = 0, b2, l;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int t, m;
    cin >> t >> m;
    if (c != 0) {
      if (a > t) {
        a = a + m;
      } else {
        a = t + m;
      }
    }
    if (c == 0) {
      a = t;
      c = 1;
      b = m;
      b2 = m;
      l = t;
      a += m;
    }
    if (c != 0 && i != 1) {
      b = b - t + l;
      if (b < 0) {
        b = 0;
      }
      b = b + m;
      l = t;
      if (b > b2) {
        b2 = b;
      }
    }
  }
  cout << a << " " << b2;
  return 0;
}
