solution
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
struct node
{
int a, c;
string b;
} records[N];
bool cmp1(node x, node y)
{
return x.a < y.a;
}
bool cmp2(node x, node y)
{
if(x.b==y.b)
return x.a<y.a;
return x.b < y.b;
}
bool cmp3(node x, node y)
{
return x.c < y.c;
}
int main()
{
int n, c;
cin >> n >> c;
for (int i = 1; i <= n; i++)
{
cin >> records[i].a >> records[i].b >> records[i].c;
}
if (c == 1)
sort(records + 1, records + 1 + n, cmp1);
if (c == 2)
sort(records + 1, records + 1 + n, cmp2);
if (c == 3)
sort(records + 1, records + 1 + n, cmp3);
for (int i = 1; i <= n; i++)
{
printf("%06d", records[i].a);
cout << " " << records[i].b << " " << records[i].c;
puts("");
}
}