#include <algorithm>
#include <iostream>
#include <vector>
struct date
{
int year;
int month;
int day;
};
std::istream& operator>>(std::istream& in, date& d)
{
return in >> d.year >> d.month >> d.day;
}
std::ostream& operator<<(std::ostream& out, const date& d)
{
return out << d.year << ' ' << d.month << ' ' << d.day;
}
int main()
{
std::vector<date> data;
date temp;
while(std::cin >> temp)
data.push_back(temp);
for(const auto d: data)
std::cout << d << '\n';
std::cout << '\n';
//Sort by year
std::sort(data.begin(), data.end(), [](const date& lhs, const date& rhs)
{ return lhs.year < rhs.year; });
for(const auto d: data)
std::cout << d << '\n';
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RydWN0IGRhdGUKewogICAgaW50IHllYXI7CiAgICBpbnQgbW9udGg7CiAgICBpbnQgZGF5Owp9OwoKc3RkOjppc3RyZWFtJiBvcGVyYXRvcj4+KHN0ZDo6aXN0cmVhbSYgaW4sIGRhdGUmIGQpCnsKICAgIHJldHVybiBpbiA+PiBkLnllYXIgPj4gZC5tb250aCA+PiBkLmRheTsKfQoKc3RkOjpvc3RyZWFtJiBvcGVyYXRvcjw8KHN0ZDo6b3N0cmVhbSYgb3V0LCAgY29uc3QgZGF0ZSYgZCkKewogICAgcmV0dXJuIG91dCA8PCBkLnllYXIgPDwgJyAnIDw8IGQubW9udGggPDwgJyAnIDw8IGQuZGF5Owp9CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6dmVjdG9yPGRhdGU+IGRhdGE7CiAgICBkYXRlIHRlbXA7CiAgICB3aGlsZShzdGQ6OmNpbiA+PiB0ZW1wKQogICAgICAgIGRhdGEucHVzaF9iYWNrKHRlbXApOwogICAgZm9yKGNvbnN0IGF1dG8gZDogZGF0YSkKICAgICAgICBzdGQ6OmNvdXQgPDwgZCA8PCAnXG4nOwogICAgc3RkOjpjb3V0IDw8ICdcbic7CiAgICAvL1NvcnQgYnkgeWVhcgogICAgc3RkOjpzb3J0KGRhdGEuYmVnaW4oKSwgZGF0YS5lbmQoKSwgW10oY29uc3QgZGF0ZSYgbGhzLCBjb25zdCBkYXRlJiByaHMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IHJldHVybiBsaHMueWVhciA8IHJocy55ZWFyOyB9KTsKICAgIGZvcihjb25zdCBhdXRvIGQ6IGRhdGEpCiAgICAgICAgc3RkOjpjb3V0IDw8IGQgPDwgJ1xuJzsKfQ==