#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[1010];
int main() {
  cin >> n;
  int ml = 0;
  int ct = 0, cl = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    cl = max(0, cl - (a[i].first - ct)) + a[i].second;
    ct = a[i].first;
    ml = max(cl, ml);
  }
  cout << ct + cl << " " << ml << "\n";
}
