eolymp
bolt
Try our new interface for solving problems
Problems

Class Time

Class Time

It's the first day of class! Tom is teaching class and first has to take attendance to see who is in class. He needs to call the students' names in alphabetical order by last name. If two students have the same last name, then he calls the students with that same last name in alphabetical order by first name. Help him! \InputFile The first line contains an integer $n~(1 \le n \le 100)$, the number of students in Tom's class. Each of the following $n$ lines contains the name of a single student: first name, followed by a single space, then last name. The first and last name both start with an uppercase letter $(A - Z)$ and then be followed by one or more lowercase letters $(a - z)$. The first and last name of each student is no more than $10$ letters long each. It is guaranteed that no two students have exactly the same name, though students may share the same first name, or the same last name. \OutputFile Output $n$ lines, the names of the students as Tom calls them in the desired order.
Time limit 1 second
Memory limit 128 MiB
Input example #1
3
John Adams
Bob Adam
Bob Adams
Output example #1
Bob Adam
Bob Adams
John Adams
Input example #2
1
Coursera Educators
Output example #2
Coursera Educators
Source 2015 ACM North America - Pacific Northwest, Дивизион 2, Задача R