#include <bits/stdc++.h>
using namespace std;
namespace Solve {
template <class T>
bool _min(T &data, const T &comp) {
  if (data > comp) {
    data = comp;
    return true;
  }
  return false;
}
template <class T>
bool _max(T &data, const T &comp) {
  if (data < comp) {
    data = comp;
    return true;
  }
  return false;
}
pair<int, int> task[1024];
void main() {
  register int i, j;
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> task[i].first >> task[i].second;
  }
  sort(task, task + n);
  int curtime = 0;
  int queuesize = 0;
  int mxqueue = 0;
  for (i = 0; i < n; ++i) {
    queuesize -= task[i].first - curtime;
    curtime = task[i].first;
    _max(queuesize, 0);
    queuesize += task[i].second;
    _max(mxqueue, queuesize);
  }
  cout << curtime + queuesize << " " << mxqueue << endl;
}
}  // namespace Solve
int main() {
  Solve::main();
  return 0;
}
