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