#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long qm = 0;
  long long prt = 0;
  long long mxs = 0;
  long long s, t = 0;
  for (int i = 0; i < n; i++) {
    cin >> t >> s;
    qm -= (t - prt);
    if (qm < 0) qm = 0;
    qm += s;
    mxs = max(mxs, qm);
    prt = t;
  }
  cout << t + qm << ' ' << mxs;
}
