#include<iostream>
#include<vector>
#include<algorithm>
//hs_10000_p   2007-01-17 19:22:53,315     253.035(s)

std::string Start(std::string s)//提取开始时间字符串
{
    int pos1 = s.find('-');
    std::string s1 = s.substr(pos1-4, 23);
    return s1;
}

double Consume(std::string s)//提取消耗时间并转换为double类型
{
    int pos1 = s.rfind("(s)");
    int pos2 = s.rfind(" ");
    std::string s1 = s.substr(pos2+1, pos1-pos2-1);
    return std::stod(s1);
}

bool Compare(std::string s1, std::string s2)//自己编写比较函数
{
    if(Consume(s1) < Consume(s2))
    {
        return true;
    }else if(Consume(s1) > Consume(s2))
    {
        return false;
    }
    return Start(s1) < Start(s2);//开始时间直接用字符串对比即可
}

int main()
{
    std::string s;
    std::vector<std::string> log;
    while(std::getline(std::cin, s))//使用getline获取整行字符串
    {
        if(s.empty()) break;
        log.push_back(s);
    }
    std::sort(log.begin(), log.end(), Compare);
    for(auto& i : log)
    {
        std::cout << i << std::endl;
    }
    log.clear();
}