#include <bits/stdc++.h>
using namespace std;
int n, t, c, nowt, lastc, nowlastc, maxlastc;
int main() {
  cin >> n;
  cin >> nowt >> lastc;
  maxlastc = lastc, nowlastc = lastc;
  for (int i = 1; i < n; i++) {
    cin >> t >> c;
    if (nowlastc - (t - nowt) >= 0)
      nowlastc -= (t - nowt), nowlastc += c;
    else
      nowlastc = c;
    maxlastc = max(maxlastc, nowlastc);
    nowt = t;
  }
  cout << nowt + nowlastc << " " << maxlastc;
  return 0;
}
