#include <bits/stdc++.h>
using namespace std;
struct xs
{
string s;
int y,m,d,k;
} a[101];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].s>>a[i].y>>a[i].m>>a[i].d;
a[i].k+=a[i].d;
}
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
if(a[i].y>a[j].y)
{
string temp;
temp=a[j].s;
a[j].s=a[i].s;
a[i].s=temp;
}
else if(a[i].y==a[j].y)
{
if(a[i].m>a[j].m)
{
string temp;
temp=a[j].s;
a[j].s=a[i].s;
a[i].s=temp;
}
else if(a[i].m==a[j].m)
{
if(a[i].d>a[i].d)
{
string temp;
temp=a[j].s;
a[j].s=a[i].s;
a[i].s=temp;
}
else
{
for(int m=1;m<=n;m++)
{
if(a[m].k=a[i].d)
{
string temp;
temp=a[j].s;
a[j].s=a[i].s;
a[i].s=temp;
break;
}
else if(a[m].k=a[j].d)
{
string temp;
temp=a[j].s;
a[j].s=a[i].s;
a[i].s=temp;
break;
}
}
}
}
}
}
}
for(int i=1;i<=n;i++) cout<<a[i].s<<endl;
return 0;
}
求助