#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cur = 0, pt = 0, mx = 0;
  for (int i = 0; i < n; i++) {
    int t, c;
    cin >> t >> c;
    cur -= (t - pt);
    if (cur < 0) cur = 0;
    cur += c;
    if (cur > mx) mx = cur;
    pt = t;
  }
  cout << pt + cur << " " << mx << endl;
  return 0;
}
