#include <bits/stdc++.h>
using namespace std;
struct student
{
string name;
int score;
};
student a [40];
bool (student x,student y)
{
return x.score<y.score;
}
int main()
{
for(int i=0;i<40;i++)
{
cin>>a[i].name>>a[i].score;
}
sort(a,a+40,cmp);
cout<<a[0].score<<a[39].score;
}