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