#include <bits/stdc++.h>
using namespace std;
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void chmin(T &t, T f) {
  if (t > f) t = f;
}
template <class T>
void chmax(T &t, T f) {
  if (t < f) t = f;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
int N;
long long T[10010], C[10010];
int main() {
  int i;
  for (; ~scanf("%d", &N);) {
    for (i = 0; i < N; ++i) {
      T[i] = in();
      C[i] = in();
    }
    long long ans = 0;
    long long t = 0;
    for (i = 0; i < N; ++i) {
      if (t <= T[i]) {
        chmax(ans, C[i]);
        t = T[i] + C[i];
      } else {
        chmax(ans, (t - T[i]) + C[i]);
        t += C[i];
      }
    }
    cout << t << " " << ans << endl;
  }
  return 0;
}
