#include <bits/stdc++.h>
using namespace std;
struct can {
string name;
int wealth;
};
bool compare(const can &a, const can &b) {
return a.wealth > b.wealth;
}
int main() {
int n = 0;
cin >> n;
vector<can>arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i].name >> arr[i].wealth ;
}
sort(arr.begin(), arr.end(), compare);
cout << arr[0].name << " " << arr[0].wealth << endl;
return 0;
}