#include <bits/stdc++.h>
using namespace std;
const int maxn = 100500;
const int infi = (1 << 30);
const long long infl = (1LL << 62);
const double eps = 1e-9;
const long long mod = 1000000007LL;
const double pi = acos(-1.0);
int n;
pair<int, int> a[1500];
int last, mx, cnt, start;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  last = mx = cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].first > last) {
      last = a[i].first + a[i].second;
      start = a[i].first + 1;
      mx = max(mx, a[i].second);
      cnt = a[i].second;
    } else {
      last = last + a[i].second;
      mx = max(mx, cnt + a[i].second - (a[i].first - start + 1));
      cnt = cnt + a[i].second;
    }
  }
  cout << last << " " << mx << endl;
  return 0;
}
