#include <iostream>
using namespace std;
struct unsortedtime {
int hours;
int minutes;
int seconds;
};
bool operator > (const unsortedtime &a, const unsortedtime &b) {
bool res = false;
if (a.hours > b.hours) res = true;
else if (a.hours == b.hours) {
if (a.minutes > b.minutes) res = true;
else if (a.minutes == b.minutes) {
if (a.seconds > b.seconds) res = true;
}
}
return res;
};
int main() {
int n;
cin >> n;
unsortedtime *a = new unsortedtime[n];
for (int i = 0; i < n; i++) {
cin >> a[i].hours >> a[i].minutes >> a[i].seconds;
}
for (int k = 2; k <= n; k++) {
for (int i = 0; i <= n - k; i++) {
if (a[i] > a[i + 1]) {
swap(a[i], a[i + 1]);
}
}
}
for (int i = 0; i < n; i++) {
cout << a[i].hours << " " << a[i].minutes << " " << a[i].seconds << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCnN0cnVjdCB1bnNvcnRlZHRpbWUgewoJaW50IGhvdXJzOwoJaW50IG1pbnV0ZXM7CglpbnQgc2Vjb25kczsKfTsKIApib29sIG9wZXJhdG9yID4gKGNvbnN0IHVuc29ydGVkdGltZSAmYSwgY29uc3QgdW5zb3J0ZWR0aW1lICZiKSB7CiAgICBib29sIHJlcyA9IGZhbHNlOwogICAgaWYgKGEuaG91cnMgPiBiLmhvdXJzKSByZXMgPSB0cnVlOwogICAgZWxzZSBpZiAoYS5ob3VycyA9PSBiLmhvdXJzKSB7CiAgICAgICAgaWYgKGEubWludXRlcyA+IGIubWludXRlcykgcmVzID0gdHJ1ZTsKICAgICAgICBlbHNlIGlmIChhLm1pbnV0ZXMgPT0gYi5taW51dGVzKSB7CiAgICAgICAgICAgIGlmIChhLnNlY29uZHMgPiBiLnNlY29uZHMpIHJlcyA9IHRydWU7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIHJlczsKfTsKIAppbnQgbWFpbigpIHsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICB1bnNvcnRlZHRpbWUgKmEgPSBuZXcgdW5zb3J0ZWR0aW1lW25dOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBjaW4gPj4gYVtpXS5ob3VycyA+PiBhW2ldLm1pbnV0ZXMgPj4gYVtpXS5zZWNvbmRzOwogICAgfQogICAgZm9yIChpbnQgayA9IDI7IGsgPD0gbjsgaysrKSB7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gbiAtIGs7IGkrKykgewogICAgICAgICAgICBpZiAoYVtpXSA+IGFbaSArIDFdKSB7CiAgICAgICAgICAgICAgICBzd2FwKGFbaV0sIGFbaSArIDFdKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgY291dCA8PCBhW2ldLmhvdXJzIDw8ICIgIiA8PCBhW2ldLm1pbnV0ZXMgPDwgIiAiIDw8IGFbaV0uc2Vjb25kcyA8PCBlbmRsOwogICAgfQogICAgcmV0dXJuIDA7Cn0=