#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int main() {
  int n;
  while (cin >> n) {
    int last = 0, cnt = 0;
    int pre = 0;
    int Max = 0;
    for (int i = 1; i <= n; i++) {
      int t, c;
      cin >> t >> c;
      if (i == 1) {
        last = t + c;
        cnt = c;
        pre = t;
        Max = max(Max, cnt);
        continue;
      }
      if (t - pre > cnt)
        cnt = c;
      else
        cnt = cnt - (t - pre) + c;
      Max = max(Max, cnt);
      if (t <= last)
        last = last + c;
      else
        last = t + c;
      pre = t;
    }
    cout << last << " " << Max << endl;
  }
  return 0;
}
