#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int n;
  cin >> n;
  int a1 = 0, b1 = 0, flag = n - 1;
  int a2, b2;
  int num = 0, m = 0, time = 0;
  while (n--) {
    cin >> a2 >> b2;
    time = a2;
    int temp = a2 - a1;
    if (temp >= num)
      num = 0;
    else
      num -= temp;
    num += b2;
    m = max(m, num);
    if (n == 0) {
      time += num;
    }
    a1 = a2;
    b1 = b2;
  }
  cout << time << " " << m << endl;
  return 0;
}
