#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  int t, c;
  int max = 0, cur = 0, lt = -1;
  for (int i = 0; i < n; i++) {
    std::cin >> t >> c;
    if (lt != -1) {
      cur += lt - t;
    }
    if (cur < 0) cur = 0;
    cur += c;
    if (cur > max) max = cur;
    lt = t;
  }
  if (cur < c) cur = c;
  std::cout << lt + cur << " " << max;
  return 0;
}
