#include <bits/stdc++.h>
struct tm_t {
  int t;
  int c;
};
int main(int argc, char** argv) {
  int i, n;
  tm_t ms[1005];
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &ms[i].t, &ms[i].c);
  }
  int max = 0;
  int cnt = 0;
  int old_time = 1;
  for (i = 0; i < n; ++i) {
    if (i == 0) {
      cnt += ms[i].c;
    } else {
      cnt -= ms[i].t - old_time;
      if (cnt < 0) {
        cnt = 0;
      }
      cnt += ms[i].c;
    }
    if (cnt > max) {
      max = cnt;
    }
    old_time = ms[i].t;
  }
  old_time += cnt;
  if (n != 0) {
    printf("%d %d\n", old_time, max);
  } else {
    printf("0 0\n");
  }
  return 0;
}
