#include <bits/stdc++.h>
using namespace std;
int n;
int t = 0, x = 0, ans = 0;
int a, b;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a, &b);
    x -= a - t;
    if (x < 0) x = 0;
    x += b;
    ans = max(ans, x);
    t = a;
  }
  printf("%d %d", t + x, ans);
  return 0;
}
