#include <bits/stdc++.h>
using namespace std;
int arr[2005][2005];
bool bol[2005][2005];
vector<long long> v;
vector<pair<int, int> > vp;
int main() {
  int n;
  cin >> n;
  long long siz = 0;
  int pc = 0;
  long long time = 0;
  for (int i = 0; i < n; i++) {
    int x, c;
    cin >> x >> c;
    if (pc > x - time)
      pc -= (x - time);
    else
      pc = 0;
    time += labs((long long)x - time);
    pc += c;
    siz = max(siz, (long long)pc);
  }
  cout << time + pc << " " << siz << endl;
}
