#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int lim = 1010;
struct state {
  int time;
  int cnt;
  state() { time = cnt = 0; }
  state(int t, int c) : time(t), cnt(c) { ; }
};
int n;
state inp[lim];
queue<state> q;
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> inp[i].time >> inp[i].cnt;
  }
}
void solve() {
  int lt = 0;
  int mx_sz = 0;
  int cur = 0;
  int sz = 0;
  int l = 0;
  while (l < n) {
    q.push(inp[l]);
    cur = inp[l].time + 1;
    sz = inp[l].cnt;
    l++;
    while (!q.empty()) {
      if (sz > mx_sz) mx_sz = sz;
      if (l == n) {
        lt = cur + q.front().cnt - 1;
        cur = lt + 1;
        sz = sz - q.front().cnt;
        q.front().cnt = 0;
        q.pop();
        if (!sz) {
          break;
        }
      } else {
        if (cur <= inp[l].time) {
          int can = min(q.front().cnt, inp[l].time - cur + 1);
          q.front().cnt -= can;
          sz -= can;
          cur = cur + can;
          if (q.front().cnt <= 0) {
            q.pop();
          }
        } else {
          sz += inp[l].cnt;
          q.push(inp[l]);
          l++;
        }
      }
    }
  }
  cout << lt << " " << mx_sz << endl;
}
int main() {
  input();
  solve();
  return 0;
}
