P1104 Birthday

Description

cjf wants to collect the birthdays of every student in the school OI group and sort them by age in descending order (older first). However, cjf has a lot of homework recently and has no time, so please help her sort them.

Input Format

The input contains $n + 1$ lines. The first line contains the total number $n$ of people in the OI group. Lines $2$ to $n + 1$ each contain one person's name $s$, birth year $y$, month $m$, and day $d$.

Output Format

Output $n$ lines. Print the names of the students in descending order of age. (If two students share the same birthday, print the one that appears later in the input first.)

Explanation/Hint

It is guaranteed that $1 < n < 100$ and $1 \leq |s| < 20$. The given dates are valid, and the year $\in [1960, 2020]$. Translated by ChatGPT 5