#include <bits/stdc++.h>
using namespace std;
long long tests;
long long n, a[1000256], b[1000256], cnt, ans;
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] - a[i - 1] < cnt) {
      cnt += b[i];
      cnt -= a[i] - a[i - 1];
    } else
      cnt = b[i];
    if (ans < cnt) ans = cnt;
  }
  cout << a[n] + cnt << " " << ans;
}
int main() { solve(); }
