#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
struct Node {
    string s;
    int year, month, day;
    int hour, min, second, ssecond;
    float time;
};
bool cmp(Node& a, Node& b) {
    if (a.time < b.time)return true;
    if (a.time == b.time) {
        if (a.year < b.year)return true;
        if (a.year == b.year) {
            if (a.month < b.month)return true;
            if (a.month == b.month) {
                if (a.day < b.day)return true;
                if (a.day == b.day) {
                    if (a.hour < b.hour)return true;
                    if (a.hour == b.hour) {
                        if (a.min < b.min)return true;
                        if (a.min == b.min) {
                            if (a.second < b.second)return true;
                            else return false;
                        }
                        else return false;
                    }
                    else return false;
                }
                else return false;
            }
            else return false;
        }
        else return false;
    }
    else return false;
}

int main() {
    vector<Node>v;
    string str;
    while (getline(cin, str)) {
        if (str == "")break;
        Node ref;
        ref.s = str;
        int index = 0;
        while (str[index] != ' ')++index;
        index += 3;
        ref.year = atoi(string(&str[index], &str[index] + 4).c_str());
        index += 5;
        ref.month = atoi(string(&str[index], &str[index] + 2).c_str());
        index += 3;
        ref.day = atoi(string(&str[index], &str[index] + 2).c_str());
        index += 3;
        ref.hour = atoi(string(&str[index], &str[index] + 2).c_str());
        index += 3;
        ref.min = atoi(string(&str[index], &str[index] + 2).c_str());
        index += 3;
        ref.second = atoi(string(&str[index], &str[index] + 2).c_str());
        index += 3;
        ref.ssecond = atoi(string(&str[index], &str[index] + 3).c_str());
        index += 4;
        while (str[index] == ' ')++index;
        int k = index;
        while (str[k] != '(')++k;
        string sss = string(&str[index], &str[0] + k).c_str();
        ref.time = atof(sss.c_str());
        v.push_back(ref);
    }
    sort(v.begin(), v.end(), cmp);
    for (auto it : v) {
        cout << it.s << endl;
    }
    /*string s = "12.3";
    cout << atof(s.c_str());*/
}
// 64 位输出请用 printf("%lld")

这代码写了我两年半