#include <bits/stdc++.h>
using namespace std;
long long t[1010], c[1010];
long long n;
int main() {
  long long mt = 0;
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; ++i) {
    scanf("%I64d%I64d", &t[i], &c[i]);
  }
  long long tot = c[1], mtot = c[1], now = t[1];
  for (long long i = 2; i <= n; ++i)
    if (now + tot > t[i]) {
      long long delta = t[i] - now;
      now += delta;
      tot -= delta;
      tot += c[i];
      mtot = max(mtot, tot);
    } else {
      now = t[i];
      tot = c[i];
      mtot = max(mtot, tot);
    }
  now += tot;
  printf("%I64d %I64d\n", now, mtot);
  return 0;
}
