#include <bits/stdc++.h>
using namespace std;
int t, s, n, tot_now, time_now, ans = -0x7fffff;
inline int get_max(int a, int b) { return a > b ? a : b; }
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) {
    t = read();
    s = read();
    tot_now -= (t - time_now);
    tot_now = get_max(tot_now, 0);
    tot_now += s;
    time_now = t;
    ans = get_max(ans, tot_now);
  }
  printf("%d %d\n", time_now + tot_now, ans);
}
