#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:167772160 )   using namespace std;   int main() {     int n;     cin >> n;     pair<int, int> x[1111];     for (int i = 0; i < n; ++i) cin >> x[i].first >> x[i].second;     long long p = 0, maxx = -1;     int j = 0;     for (int i = 0; i < x[n - 1].first; i++) {       if (p != 0) --p;       if (i == x[j].first - 1) {         p += x[j].second;         ++j;       }       if (p > maxx) maxx = p;     }     cout << x[n - 1].first + p <<     << maxx << endl;     return 0;   }   