#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, k, l, a[10000000], ma, ans, x, y, ma1, r;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    if (i == n) ma1 = x;
    a[x] += y;
  }
  for (i = 1; i <= 1000000; i++) {
    r = max(0LL, r - 1);
    r += a[i];
    if (r > ma) ma = r;
    if (i == ma1) ans = r + i;
  }
  cout << ans << " " << ma << endl;
}
