#include <iostream>
#include<algorithm>
#include<sstream>
using namespace std;
typedef struct taskLog {
string total_log;
string begin_date;
string begin_time;
float dur;
}taskLog;
struct taskLog t[5000];
bool cmp(taskLog& a, taskLog& b){
if(a.dur!=b.dur){
return a.dur<b.dur;
}
if(a.begin_date!=b.begin_date){
return a.begin_date<b.begin_date;
}
return a.begin_time<b.begin_time;
}
int main() {
string s;
int i = 0;
while (getline(cin, s)) { // 注意 while 处理多个 case
if (s == "")break;
t[i].total_log=s;
bool flag = false;
stringstream ss(s);
string token;
int cnt=0;
while(ss>>token){
if(cnt==1){
t[i].begin_date=token;
}
else if(cnt==2){
t[i].begin_time=token; ;
}
else if(cnt==3){
t[i].dur=stof(token.substr(0,token.length()-3));
}
cnt++;
}
i++;
}
sort(t,t+i,cmp);
for(int j=0;j<i;j++)cout<<t[j].total_log<<endl;
}
// 64 位输出请用 printf("%lld")