#include <bits/stdc++.h>
long m[1001 * 2] = {0};
int main() {
  long n, t = 0, i, u = 0, o = 0, q = 0;
  scanf("%ld", &n);
  for (i = 0; i < n; i++) {
    scanf("%ld%ld", &m[i * 2], &m[i * 2 + 1]);
  }
  t = 0;
  q = 0;
  u = 0;
  while (u < n) {
    t++;
    if (q > 0) q--;
    if (!q) t = m[2 * u];
    if (m[2 * u] == t) {
      q += m[2 * u + 1];
      if (q > o) o = q;
      u++;
    }
  }
  t += q;
  printf("%ld %ld", t, o);
  return 0;
}
