#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e4+10;
int t,n,m,k,l,r,op,x,y;
struct nd{
string info;
string name;
int ye,mo,da,ho,mi,se,ms;
double ti;
bool operator<(const nd&nd1){
if(ti!=nd1.ti)return ti<nd1.ti;
ll t1 = ye*1e13+mo*1e11+da*1e9+ho*1e7+mi*1e5+se*1e3;
ll t2 = nd1.ye*1e13+nd1.mo*1e11+nd1.da*1e9+nd1.ho*1e7+nd1.mi*1e5+nd1.se*1e3;
return t1<t2;
}
};
nd ndd[N];
string name;
void solve(){
int i;
for(i = 1;;i++){
getline(cin,ndd[i].info);
if(ndd[i].info.empty())break;
sscanf(ndd[i].info.c_str(),"%s %d-%d-%d %d:%d:%d,%d %lf(s)",&ndd[i].name[0],&ndd[i].ye,&ndd[i].mo,&ndd[i].da,&ndd[i].ho,&ndd[i].mi,&ndd[i].se,&ndd[i].ms,&ndd[i].ti);
}
i--;
sort(ndd+1,ndd+1+i);
for(int j = 1;j<=i;j++){
cout<<ndd[j].info<<"\n";
}
}
int main(){
solve();
return 0;
}