#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> t, c;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    t.push_back(x);
    cin >> x;
    c.push_back(x);
  }
  long l = 0, maxl = 0;
  for (int i = t[0]; i <= t[n - 1]; ++i) {
    if (l != 0) l--;
    for (int j = 0; j < n; ++j)
      if (t[j] == i) {
        l += c[j];
        break;
      }
    if (l > maxl) maxl = l;
  }
  long tm = l + t[t.size() - 1];
  cout << tm << ' ' << maxl;
  return 0;
}
