eolymp
Competitions

Робота з рядками

Personal files

One day, an awkward secretary messed up personal affairs of students. Now they again need to order first by grade, and within a class by name.

Input

The first line contains the number of personal affairs n (1n1000). Next to each of the n students the following data (each in its own line): full name, grade, date of birth. Surname and name - string of no more than 20 characters, the class - a string consisting of a number (from 1 to 11) and a letter (from "A" to "Z"), date of birth - the date in the format DD.MM.YY. It is guaranteed that there are no namesakes within the same class.

Output

Print n lines, each of which contains the data for one student. Rows should be arranged first by class and then by last name.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
Sidorov
Sidor
9A
20.07.93
Petrov
Petr
11B
23.10.92
Ivanov
Ivan
9A
10.04.93

Output example #1
9A Ivanov Ivan 10.04.93
9A Sidorov Sidor 20.07.93
11B Petrov Petr 23.10.92