#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128777216")
const long long LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
using namespace std;
void prepare(string s) {
  if (s.length() != 0) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
const int NMAX = 100100;
int main() {
  clock_t time = clock();
  prepare("");
  int n = 0, t, c, T = 0, C = 0;
  cin >> n;
  for (int i = 0; i < (int)n; i++) {
    cin >> t >> c;
    if (T == 0) T = t;
    T = max(T, t);
    T += c;
    C = max(C, T - t);
  }
  cout << T << ' ' << C;
  time = clock() - time;
  return 0;
}
