#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int size;
  int last;
  cin >> last >> size;
  int ans = size;
  for (int i = 1; i < n; i++) {
    int t, c;
    cin >> t >> c;
    int timePassed = t - last;
    ans = max(size, ans);
    size = max(0, size - timePassed);
    size += c;
    last = t;
    ans = max(size, ans);
  }
  cout << last + size << ' ' << ans << endl;
  return 0;
}
