#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int smsCount = 0;
  int maxSMS = 0;
  int lastTime = 0;
  int lastSent = 0;
  for (int i = 0; i < n; ++i) {
    int t, c;
    cin >> t >> c;
    int count = t - lastTime;
    int toSend = min(count, smsCount);
    if (toSend >= 0) {
      lastSent = lastTime + toSend;
      smsCount -= toSend;
    }
    smsCount += c;
    if (smsCount >= maxSMS) {
      maxSMS = smsCount;
    }
    lastTime = t;
  }
  if (smsCount > 0) {
    lastSent = lastTime + smsCount;
  }
  cout << lastSent << " " << maxSMS << endl;
  return 0;
}
