Birthday

No attempts yetTime limit1sMemory limit128 MB

Problem

Given the birthdays of the students in a class, write a program that finds the youngest student and the oldest student.

Input

The first line contains the number of students $n$ in the class. ($1 \le n \le 100$)

Each of the next $n$ lines contains a student's name and birthday in the format "name dd mm yyyy". The name is that student's name, consisting of at most 15 characters. dd, mm, and yyyy are the day, month, and year of the birthday. ($1990 \le yyyy \le 2010$, $1 \le mm \le 12$, $1 \le dd \le 31$) Every given birthday is a valid date, and the year, month, and day do not have leading zeros.

No two students share the same name or the same birthday.

Output

Print the name of the youngest student on the first line, and the name of the oldest student on the second line.