Choosing the Morgorithm President
InterviewTime limit1sMemory limit1024 MB
Given N distinct uppercase names, print the one that comes first in dictionary order among those with exactly three characters.
Problem
Taeyun, the president of Morgorithm, is choosing the person who will lead Morgorithm in 2024. Nobody wants the job, so Taeyun picks the president himself. He plans to choose the person who comes first in dictionary order among those whose names have exactly three characters.
Every name is different and consists of uppercase letters A - Z, with a length from to .
Name comes before name in dictionary order if and only if one of the following holds. Here is the length of , and is the -th character of .
- is a prefix of . That is, , and for every .
- At the first index where (with ), .
Predict who will be chosen as president.
Input
The first line contains , the number of people.
The next lines contain the names through .
Output
Print the name of the person who will be chosen as president.
Constraints
- At least one person has a name of exactly three characters.
- Each name is given at most once.