#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long f = 0;
  char ch = getchar();
  while (!(ch >= '0' && ch <= '9')) ch = getchar();
  while (ch >= '0' && ch <= '9') f = f * 10 + ch - 48, ch = getchar();
  return f;
}
long long t[1001], a[100001], sum, m, n, maxn;
int main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    t[i] = read();
    a[i] = read();
  }
  for (m = 1; m <= n; m++) {
    sum = sum - (t[m] - t[m - 1]);
    sum = max(sum, (long long)0);
    sum += a[m];
    maxn = max(sum, maxn);
  }
  m = t[n] + sum;
  printf("%I64d %I64d", m, maxn);
}
