#include <bits/stdc++.h>
using namespace std;
int t[1001], c[1001];
int main() {
  int n, i, last_time, max_size, size_now, temp;
  cin >> n;
  for (i = 0; i < n; i++) cin >> t[i] >> c[i];
  size_now = c[0];
  max_size = c[0];
  for (i = 1; i < n; i++) {
    temp = t[i] - t[i - 1];
    if (size_now == 0)
      size_now += c[i];
    else {
      size_now -= temp;
      if (size_now < 0) size_now = 0;
      size_now += c[i];
    }
    max_size = max(size_now, max_size);
  }
  last_time = size_now + t[n - 1];
  cout << last_time << " " << max_size << endl;
  return 0;
}
