#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
int nextint() {
  int a;
  scanf("%d", &a);
  return a;
}
double nextdouble() {
  double a;
  scanf("%lf", &a);
  return a;
}
bool equal(double a, double b) { return fabs(a - b) < EPS; }
class item {
 public:
  item(int t = 0, int c = 0) : t(t), c(c) {}
  int t, c;
};
int main() {
  int n = nextint();
  vector<item> v(n);
  for (int i = 0; i < n; i++) {
    v[i].t = nextint();
    v[i].c = nextint();
  }
  int sz = 0;
  int prevt = 0;
  int maxsz = 0;
  for (int i = 0; i < n; i++) {
    sz = max(0, sz - (v[i].t - prevt));
    sz += v[i].c;
    prevt = v[i].t;
    maxsz = max(maxsz, sz);
  }
  cout << prevt + sz << " " << maxsz << endl;
  return 0;
}
