#include <bits/stdc++.h>
using namespace std;
struct Zadanie {
  int t;
  int c;
};
int main() {
  int n;
  cin >> n;
  Zadanie Zadanie[n];
  int s[n];
  for (int i = 0; i < n; ++i) cin >> Zadanie[i].t >> Zadanie[i].c;
  s[0] = Zadanie[0].c;
  for (int i = 1; i < n; ++i)
    s[i] = (s[i - 1] - (Zadanie[i].t - Zadanie[i - 1].t)) *
               (1 && ((s[i - 1] - (Zadanie[i].t - Zadanie[i - 1].t)) > 0)) +
           Zadanie[i].c;
  int imax;
  imax = 0;
  for (int i = 0; i < n; ++i)
    if (s[i] > s[imax]) imax = i;
  cout << Zadanie[n - 1].t + s[n - 1] << " " << s[imax];
  return 0;
}
