#include <iostream>
using namespace std;
int main(){
int a;
cin>>a;
int b[a],c[a];
for(int i=0;i<a;i++){
cin>>b[i]>>c[i];
}
int max=-1,index,wrong=0;
for (int i=0;i<a;i++){
if(c[i]>max){
max=c[i];
index=i;
}
if(c[i]==-1){
wrong++;
}
}
max=max-a-2*wrong;
if(max<0){
cout<<"0 "<<b[index];
}
else{
cout<<max<<" "<<b[index];
}
}