#include <iostream>
using namespace std;
int main()
{
int n, s;
string a;
cin >> n;
int maxs = 0;
string name = "";
while (n--)
{
cin >> s >> a;
if (maxs < s)
{
maxs = s;
name = a;
}
}
cout << name;
return 0;
}