#include <bits/stdc++.h>
using namespace std;
bool compTasks(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second < b.second;
  }
}
int main() {
  int a;
  cin >> a;
  vector<pair<int, int>> tasks;
  for (int i = 0; i < a; i++) {
    int c, d;
    cin >> c >> d;
    tasks.push_back(make_pair(c, d));
  }
  sort(tasks.begin(), tasks.end(), compTasks);
  int maxMessage = 0;
  int messageSize = 0;
  int prevTime = 0;
  int time = 0;
  for (int i = 0; i < tasks.size(); i++) {
    pair<int, int> currentPair = tasks.at(i);
    int currentTime = currentPair.first;
    int currentMsg = currentPair.second;
    if (time <= currentTime) {
      time = currentTime + currentMsg;
      messageSize = currentMsg;
    } else {
      time += currentMsg;
      messageSize -= (currentTime - prevTime);
      messageSize += currentMsg;
    }
    if (messageSize > maxMessage) {
      maxMessage = messageSize;
    }
    prevTime = currentTime;
  }
  cout << time << " " << maxMessage;
}
