#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
int n;
int m;
int main() {
  int n;
  pair<int, int> ev[2000];
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> ev[i].first >> ev[i].second;
  }
  int len = 0;
  int t = 0;
  int maxlen, maxt;
  maxlen = maxt = 0;
  for (int i = 0; i < (n); i++) {
    len = max(0, len - (ev[i].first - t));
    len += ev[i].second;
    maxlen = max(maxlen, len);
    maxt = max(maxt, ev[i].first + len);
    t = ev[i].first;
  }
  cout << maxt << ' ' << maxlen << endl;
  return 0;
}
