#include <bits/stdc++.h>
using namespace std;
int gcd(int m, int n) {
  int r;
  while (n != 0) {
    r = m % n;
    m = n;
    n = r;
  }
  return m;
}
long long int q[1000001];
int main() {
  int n;
  cin >> n;
  long long int t[n], c[n];
  for (int i = 0; i < n; i++) cin >> t[i] >> c[i];
  memset(q, 0, sizeof(q));
  q[t[0]] = c[0];
  long long int mx = q[t[0]];
  for (int i = 1; i < n; i++) {
    q[t[i]] = max(c[i], c[i] + (q[t[i - 1]] - (t[i] - t[i - 1])));
    mx = max(q[t[i]], mx);
  }
  cout << (q[t[n - 1]] + t[n - 1]) << " " << mx << endl;
  return 0;
}
