#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<int, int>> data(n);
// 存入資料
for (int i = 0; i < n; i++) {
cin >> data[i].first >> data[i].second;
}
// 計算最高分時間
auto maxScoreTime = max_element(data.begin(), data.end(),
[](const pair<int, int>&a, const pair<int, int>&b) {
return a.second < b.second;
})-> first;
// 計算重大錯誤次數
int counter = count_if(data.begin(), data.end(),
[](const pair<int, int>&c) {
return c.second == -1;
});
// 計算最高分數
auto maxScore = max_element(data.begin(), data.end(),
[](const pair<int, int>&a, const pair<int, int>&b) {
return a.second < b.second;
})-> second;
int totalScore = maxScore - n - (counter*2);
// 避免總分為負的
if (totalScore < 0) totalScore = 0;
cout << totalScore << " " << maxScoreTime << endl;
return 0;
}