A tournament tracks each player's score and number of wins. Produce the final standings by sorting the players with this exact comparator:
- Higher
scoreranks first. - If scores tie, higher
winsranks first. - If both tie, the player whose
nameis lexicographically smaller ranks first.
Player names are lowercase letters only and are guaranteed to be distinct, so the ordering is uniquely determined.
Input format
Line 1: an integer n — the number of players.
Next n lines: each contains name score wins separated by single spaces.
Output format
Print n lines. Line i contains name score for the player ranked i-th (1-indexed) in the standings. (Wins are used only for ordering and are not printed.)
Constraints
- 1 ≤ n ≤ 100000
- 0 ≤ score ≤ 1000000000
- 0 ≤ wins ≤ 1000000
- Each name is 1–20 lowercase Latin letters; all names are distinct.