#include <bits/stdc++.h>
using namespace std;
int p, l, t, c, m, n, i, k, o;
int main() {
  cin >> n;
  cin >> p >> l;
  m = l;
  for (i = 1; i < n; i++) {
    cin >> t >> c;
    l = l - (t - p);
    if (l < 0) l = 0;
    l += c;
    p = t;
    if (l > m) m = l;
  }
  cout << (p + l) << " " << m;
}
