#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct student{
int id;
char name[10];
int sorce;
}stu[100010];
bool cmp1(student a,student b)
{
return a.id<b.id;
}
bool cmp2(student a,student b)
{
if(strcmp(a.name,b.name)==0)
return a.id<b.id;
else return strcmp(a.name,b.name)<0;
}
bool cmp3(student a,student b)
{
if(a.sorce!=b.sorce) return a.sorce<b.sorce;
else return a.id<b.id;
}
int main(){
int i,n,p;
scanf("%d%d",&n,&p);
for(i=0;i<n;i++){
scanf("%d%s%d",&stu[i].id,stu[i].name,&stu[i].sorce);
}
if(p==1) sort(stu,stu+n,cmp1);
if(p==2) sort(stu,stu+n,cmp2);
if(p==3) sort(stu,stu+n,cmp3);
for(i=0;i<n;i++)
{
printf("%06d %s %d\n",stu[i].id,stu[i].name,stu[i].sorce);
}
return 0;
}
Sample Input 1
3 1
000007 James 85
000010 Amy 90
000001 Zoe 60
Sample Output 1
000001 Zoe 60
000007 James 85
000010 Amy 90
Sample Input 2
4 2
000007 James 85
000010 Amy 90
000001 Zoe 60
000002 James 98
Sample Output 2
000010 Amy 90
000002 James 98
000007 James 85
000001 Zoe 60
Sample Input 3
4 3
000007 James 85
000010 Amy 90
000001 Zoe 60
000002 James 90
Sample Output 3
000001 Zoe 60
000007 James 85
000002 James 90
000010 Amy 90