#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
const int N=10010;
struct record{
    string name;
    string date;
    string start_time;
    double task_time;
    string line;
}a[N];

bool cmp(record &a,record &b){
    if(a.task_time!=b.task_time) return a.task_time<b.task_time;
    else {
        if(a.date!=b.date) return a.date<b.date;
        else return a.start_time<b.start_time;
    }
}
int main() {
    string line;
    int i=0;
    while(getline(cin,line)){
        a[i].line=line;
        stringstream ssin(line);
        ssin>>a[i].name>>a[i].date>>a[i].start_time>>a[i].task_time;//不用管类型,ssin>>读入即可
        i++;
    }
    sort(a,a+i,cmp);
    for(int j=0;j<i;j++){
        cout<<a[j].line<<endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")