#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
string s[n];
int a[n];
double sum = 0;
for (int i = 0; i < n; i++)
cin >> s[i] >> a[i], sum += a[i];
sum = sum / n / 2;
int j = 0;
for (int i = 0; i < n; i++)
if (fabs(sum - a[i]) < fabs(sum - a[j]))
j = i;
cout << (int)sum << ' ' << s[j];
return 0;
}