#include <bits/stdc++.h>
using namespace std;
int n, t, c;
long long m, s, maxn;
int main() {
  cin >> n;
  while (n--) {
    cin >> t >> c;
    s -= t - m;
    s = max(s, 0ll);
    s += c;
    maxn = max(maxn, s);
    m = t;
  }
  cout << m + s << " " << maxn << endl;
  return 0;
}
