#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> sms;
  int time1, amount1;
  for (int i = 0; i < n; i++) {
    cin >> time1 >> amount1;
    sms.push_back(make_pair(time1, amount1));
  }
  int time = 0;
  int amount = 0;
  int maxamount = 0;
  for (int i = 0; i < n; i++) {
    if (amount <= sms[i].first - time) {
      time = sms[i].first;
      amount = sms[i].second;
    } else {
      amount -= sms[i].first - time;
      time += sms[i].first - time;
      amount += sms[i].second;
    }
    if (amount > maxamount) maxamount = amount;
  }
  if (amount) {
    if (amount > maxamount) maxamount = amount;
    time += amount;
  }
  cout << time << ' ' << maxamount << endl;
  return 0;
}
