#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, Max = 0, a, b, l = 0, n, x;
  cin >> n;
  cin >> a >> b;
  l += b;
  x = a;
  Max = max(Max, l);
  for (i = 2; i <= n; i++) {
    cin >> a >> b;
    l -= (a - x);
    l = max(l, 0);
    l += b;
    Max = max(Max, l);
    x = a;
  }
  cout << x + l << " " << Max;
  return 0;
}
