#include <bits/stdc++.h>
using namespace std;
int x, y, t;
int main() {
  int i, j, k, n;
  cin >> n;
  for (i = 1; i <= n; i++) {
    int s1, s2;
    cin >> s1 >> s2;
    x -= (s1 - t);
    if (x < 0) x = 0;
    x += s2;
    y = max(x, y);
    t = s1;
  }
  cout << x + t << " " << y << endl;
  return 0;
}
