#include <bits/stdc++.h>
using namespace std;
int Max, a, b, q, la, n, x;
int main() {
  cin >> n;
  scanf("%d%d", &a, &b);
  la = b;
  x = a;
  Max = la;
  for (register int i = 2; i <= n; ++i) {
    scanf("%d%d", &a, &b);
    la -= (a - x);
    la = max(la, 0);
    la += b;
    Max = max(Max, la);
    x = a;
  }
  cout << x + la << ' ' << Max;
  return 0;
}
