#include <bits/stdc++.h>
using namespace std;
int i, n, k, m, j, con, r;
long long int tmp, minm, maks, isi, t;
queue<int> q;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%I64d%d", &t, &k);
    for (j = 0; j < abs(tmp - t); j++)
      if (isi != 0) {
        isi--;
      }
    isi += k;
    maks = max(maks, isi);
    tmp = t;
  }
  while (isi--) {
    t++;
  }
  printf("%I64d %I64d\n", t, maks);
  return 0;
}
