#include <bits/stdc++.h>
using namespace std;
struct people{
string name;
int num;
}p[10010];//是十的四次方多一点,开小了就就会溢出导致段错误。
int main(){
int n;
cin>>n;
int sum = 0;
for(int i=0;i<n;i++){
cin>>p[i].name>>p[i].num;
sum+=p[i].num;
}
int minn = 100;
int t=0;
for(int i=0;i<n;i++){
if(abs(p[i].num-sum/n/2)<minn){
minn=abs(p[i].num-sum/n/2);
t = i;//用t记录最后minn对应的i
}
}
cout<< sum/n/2<<' '<<p[t].name<<endl;
return 0;
}