#include<iostream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;

const int N = 1e5 + 10;

struct Log{
	string line;    //原来的输入行 
	string name; //任务名称
	string year;  //开始时间
	string date;
	float time;   //耗时 
}logs[N];

bool cmp(Log l1,Log l2)
{
	if(l1.time == l2.time)
	{
		if(l1.year == l2.year) return l1.date < l2.date;
		return l1.year < l2.year;
	}
	return l1.time < l2.time;
}

int main(void)
{
	int i = 0;
	while(getline(cin,logs[i].line))
	{
		istringstream iss(logs[i].line);
		iss >> logs[i].name >> logs[i].year >> logs[i].date >> logs[i].time;
		i++;
	}
	sort(logs,logs + i,cmp);
	for(int j = 0;j < i;j++)
	{
		printf("%s\n",logs[j].line.c_str());
//		cout << logs[j].line << endl;
	}
	
	return 0;
}