#include <bits/stdc++.h>
using namespace std;
queue<int> q;
int t[1010], c[1010], qsiz[1010];
int main() {
  int n, i, j, tim, ans, siz;
  while (cin >> n) {
    for (i = 1; i <= n; i++) {
      scanf("%d%d", &t[i], &c[i]);
    }
    memset(qsiz, 0, sizeof(qsiz));
    tim = 0;
    ans = siz = 0;
    for (i = 1; i <= n; i++) {
      if (t[i] > tim) {
        siz = c[i] + max(0, tim + siz - t[i]);
        ans = max(ans, siz);
        tim = t[i];
      }
    }
    tim = 1;
    i = 0;
    for (;;) {
      if (i <= n && tim > t[i]) {
        for (; i <= n; i++) {
          if (tim >= t[i])
            q.push(c[i]);
          else
            break;
        }
      } else if (q.empty()) {
        if (i > n)
          break;
        else {
          tim = t[i] + c[i];
          i++;
          continue;
        }
      } else {
        tim += q.front();
        q.pop();
      }
    }
    cout << tim << " " << ans << endl;
  }
}
