#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int q = 0;
  int p = 0;
  int m = 0;
  for (int i = 0; i < n; ++i) {
    int t, x;
    cin >> t >> x;
    q = max(0, q - (t - p));
    q += x;
    m = max(m, q);
    p = t;
  }
  cout << p + q << " " << m;
  return 0;
}
