#include <bits/stdc++.h>
int n, t, x, mx, temp1, temp2;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &temp1, &temp2);
    x -= temp1 - t;
    if (x < 0)
      x = temp2;
    else
      x += temp2;
    if (x > mx) mx = x;
    t = temp1;
  }
  printf("%d %d\n", t + x, mx);
  return 0;
}
