Under construction

Still being built. Things may change

Choosing the Morgorithm President

Interview

Time limit1sMemory limit1024 MB

Summary
Given N distinct uppercase names, print the one that comes first in dictionary order among those with exactly three characters.
Level

Easy2 of 10

Topics
String, Array
Solved
No attempts yet

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 22 to 55.

Name SS comes before name TT in dictionary order if and only if one of the following holds. Here ∣S∣|S| is the length of SS, and S[i]S[i] is the ii-th character of SS.

  • SS is a prefix of TT. That is, ∣S∣<∣T∣|S| < |T|, and S[i]=T[i]S[i] = T[i] for every 1≤i≤∣S∣1 \leq i \leq |S|.
  • At the first index ii where S[i]≠T[i]S[i] \neq T[i] (with 1≤i≤min⁡(∣S∣,∣T∣)1 \leq i \leq \min(|S|, |T|)), S[i]<T[i]S[i] < T[i].

Predict who will be chosen as president.

Input

The first line contains NN, the number of people.

The next NN lines contain the names name1name_1 through nameNname_N.

Output

Print the name of the person who will be chosen as president.

Constraints

  • 1≤N≤100 0001 \leq N \leq 100\,000
  • 2≤∣namei∣≤52 \leq |name_i| \leq 5
  • At least one person has a name of exactly three characters.
  • Each name is given at most once.

Examples1

  1. Example 1

    Input
    7
    KGW
    LH
    AHC
    LKY
    DREAM
    AA
    KTY
    
    Expected output
    AHC