#K12361. Find the Youngest Person

    ID: 23674 Type: Default 1000ms 256MiB

Find the Youngest Person

Find the Youngest Person

In this problem, you are given (T) test cases. Each test case begins with an integer (n) representing the number of people followed by (n) lines. Each line contains a person's name and their birthdate in the format YYYY-MM-DD. Your task is to determine the youngest person in each test case. A person with a later birthdate is considered younger. Note that if two people share the same birthdate, the one appearing first as per the input order among those with the maximum birthdate is considered the youngest.

For example, if the input for one test case is:

3
Alice 1990-05-01
Bob 1985-12-24
Charlie 1992-08-17

The output should be:

Charlie

This is because (\text{1992-08-17}) is later than both (\text{1990-05-01}) and (\text{1985-12-24}).

inputFormat

The input is read from standard input (stdin). The first line contains an integer (T), the number of test cases. For each test case, the first line contains an integer (n), the number of people. Each of the next (n) lines contains a person's name (a string without spaces) and a birthdate in the format YYYY-MM-DD, separated by a space.

outputFormat

For each test case, output the name of the youngest person. Each result should be printed on a new line to standard output (stdout).## sample

2
3
Alice 1990-05-01
Bob 1985-12-24
Charlie 1992-08-17
2
Dave 2000-04-30
Eve 1999-01-15
Charlie

Dave

</p>