#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3, INF = 1e9;
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  long long n, last = 0, id = 0, ans = 0, i = 0;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (auto &t : v) cin >> t.first >> t.second;
  for (; i <= N; ++i) {
    if (last) last--;
    if (v[id].first == i) {
      last += v[id].second;
      id++;
    }
    ans = max(ans, last);
    if (id == v.size()) {
      break;
    }
  }
  ans = max(ans, last);
  cout << i + last << ' ' << ans << endl;
  return 0;
}
