#include <bits/stdc++.h>
using namespace std;
int ans[20001][667];
int main(){
ios_base::sync_with_stdio(0);
cin.tie();
int k;
cin>>k;
vector<int> time(k),score(k);
int all=-1*k,maxs=-1;
int maxt;
for(int i=0;i<k;i++){
cin>>time[i]>>score[i];
if(score[i]>maxs){
maxt=time[i];
maxs=score[i];
}
if(score[i]==-1){
all-=2;
}
}
all+=maxs;
if(all<0){
all=0;
}
cout<<all<<' '<<maxt<<endl;
}