#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int max = 1000 * 1000 * 3;
  cin >> n;
  int* d = new int[max];
  for (int i = 0; i < max; i++) d[i] = 0;
  int x, t;
  for (int i = 0; i < n; i++) {
    cin >> x >> t;
    d[x] += t;
  }
  int mx = 0, pt = 0;
  int in = 0;
  for (int i = 0; i < max || in; i++) {
    if (in > 0) in--;
    if (i < max) in += d[i];
    if (in > mx) mx = in;
    if (in) pt = i + 1;
  }
  cout << pt << " " << mx << endl;
  return 0;
}
