#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  int max_size = 0;
  int cur_size = 0;
  cin >> n;
  int cur_t = 0;
  int max_s = 0;
  for (int i = 0; i < int(n); i++) {
    int t, c;
    cin >> t >> c;
    cur_size = max(0, cur_size - (t - cur_t));
    cur_t = t;
    cur_size += c;
    max_size = max(cur_size, max_size);
  }
  cout << cur_t + cur_size << " " << max_size << endl;
  return 0;
}
