#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
struct info {
  int t, c;
} sm[MAXN];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &sm[i].t, &sm[i].c);
  int en = 0, nowq = 0, Maxq = 0;
  for (int i = 1; i <= n; ++i) {
    nowq =
        (0 > nowq - (sm[i].t - sm[i - 1].t) ? 0
                                            : nowq - (sm[i].t - sm[i - 1].t));
    nowq += sm[i].c;
    Maxq = (Maxq > nowq ? Maxq : nowq);
    en = (en > sm[i].t + nowq ? en : sm[i].t + nowq);
  }
  printf("%d %d\n", en, Maxq);
  return 0;
}
