#include <bits/stdc++.h>
using namespace std;
int c[2000007], t[2000007];
int main() {
  int ma = 0, ti = 0, lo = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> c[i];
  }
  int j = 0;
  for (int i = 1; i <= t[n - 1]; i++) {
    if (t[j] != i) {
      if (lo > 0) lo--;
    } else {
      lo += c[j];
      if (lo > c[j]) lo--;
      ma = (lo > ma ? lo : ma);
      j++;
    }
  }
  cout << t[n - 1] + lo << " " << ma;
  return 0;
}
