链接:http://noi.openjudge.cn/ch0110/08/
#include<bits/stdc++.h>
using namespace std;
struct node
{
string id;
int age,k;
}s[150];
bool cmp(node a,node b)
{
/*if(a.age>=60&&b.age>=60&&a.age!=b.age)
return a.age>b.age;
if(a.age>=60&&b.age>=60&&a.age==b.age)
return a.k<b.k;*/
if(a.age>=60&&b.age>=60)
return a.age>b.age;
if(a.age>=60&&b.age<60)
return true;
if(a.age<60&&b.age>=60)
return false;
else
return a.k<b.k;
}
int main()
{
int n;
//freopen("t.txt","r",stdin);
scanf("%d",&n);
for(int i=0;i<n;i++)
{
cin>>s[i].id;
scanf("%d",&s[i].age);
s[i].k=i;
}
stable_sort(s,s+n,cmp);
for(int i=0;i<n;i++)
{
//printf("%06d\n",s[i].id);
cout<<s[i].id<<endl;
}
return 0;
}