#include <bits/stdc++.h>
using namespace std;
void initfiles() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
int n;
int t[1000];
int c[1000];
void Solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> t[i] >> c[i];
  int qLen = c[0];
  int ans = qLen;
  for (int i = 1; i < n; ++i) {
    qLen -= t[i] - t[i - 1];
    if (qLen < 0) qLen = 0;
    qLen += c[i];
    ans = max(ans, qLen);
  }
  cout << t[n - 1] + qLen << ' ' << ans << endl;
}
int main() {
  Solve();
  return 0;
}
