#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
int main() {
  int i, ans, num, t;
  scanf("%d", &n);
  scanf("%d%d", &t, &num);
  ans = num;
  for (i = 2; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x - t >= num)
      num = y;
    else
      num = num - (x - t) + y;
    t = x;
    ans = max(ans, num);
  }
  cout << t + num << " " << ans;
  return 0;
}
