#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unsigned long int t[n], c[n], tt, cc, max;
  for (int i = 0; i < n; i++) cin >> t[i] >> c[i];
  tt = t[0];
  max = cc = c[0];
  for (int i = 1; i < n; i++) {
    while (tt != t[i]) {
      if (cc > 0) cc--;
      tt++;
    }
    cc = cc + c[i];
    if (cc > max) max = cc;
  }
  cout << (tt + cc) << " " << max << endl;
  return 0;
}
