Korean, English, math

No attempts yetTime limit1sMemory limit256 MB

Problem

You are given the name and the Korean, English, and math scores of N students. Write a program that sorts the students by the following rules, applied in order.

  1. Korean score in decreasing order
  2. If the Korean scores are equal, English score in increasing order
  3. If the Korean and English scores are equal, math score in decreasing order
  4. If all three scores are equal, name in increasing dictionary order

Names are compared by ASCII value. An uppercase letter has a smaller value than a lowercase letter, so it comes first.

Input

The first line contains the number of students N (1N1000001 \le N \le 100000).

Each of the next N lines contains a student's name and Korean, English, and math scores, separated by single spaces. Every score is a natural number between 1 and 100. A name consists only of uppercase and lowercase letters and is at most 10 characters long. Two or more students may share the same name.

Output

Print the name of each student on its own line, N lines in total, in the sorted order.