#include<stdio.h>
#include<string.h>
struct country
{
int order;
char name[20];
int number;
char continent[20];
};
int main()
{
struct country cou[100],temp;
int n,i,j;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%d %s %d %s",&cou[i].order,cou[i].name,&cou[i].number,cou[i].continent);
for(i=0;i<n;i++)
if(strcmp(cou[i].name,"China")==0)
{
temp=cou[i];
cou[i]=cou[n-1];
cou[n-1]=temp;
}
for(i=0;i<n-2;i++)
for(j=0;j<n-2-i;j++)
if(strcmp(cou[i].name,cou[i+1].name)>0)
{
temp=cou[i];
cou[i]=cou[i+1];
cou[i+1]=temp;
}
for(i=0;i<n;i++)
printf("%d %s %d %s\n",cou[i].order,cou[i].name,cou[i].number,cou[i].continent);
}
return 0;
}