e-olymp
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 N (1N1000) - the number of personal affairs. 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 numbers (from 1 to 11) and letters (from "A" to "Z"), date of birth - the date in the format MM.DD.YY. It is guaranteed that within a single class there namesakes.

Output

The output file you want to display N lines, each of which recorded data for one student. Rows should be arranged first by class and then by last name.

Time limit 1 second
Memory limit 64 MiB
Input example
3
Sidorov
Sidor
9A
20.07.93
Petrov
Petr
10B
23.10.92
Ivanov
Ivan
9A
10.04.93
Output example
9A Ivanov Ivan 10.04.93
9A Sidorov Sidor 20.07.93
10B Petrov Petr 23.10.92