#C9790. Most Mentioned Handle

    ID: 53922 Type: Default 1000ms 256MiB

Most Mentioned Handle

Most Mentioned Handle

You are given a list of comments. Each comment may contain one or more user mentions in the format @handle, where handle consists of one or more alphanumeric characters (including underscores). Your task is to determine the most frequently mentioned handle among all comments. In the event of a tie, return the lexicographically smallest handle.

For example, consider the following comments:

Great job @john and @jane!
I think @john really nailed it.
What do you think, @john?
@jane did well too!
@lisa, @john, and @jane all did great!

Here, the handle john is mentioned the most frequently, so the output should be john.

inputFormat

The input is given via standard input (stdin). The first line contains a single integer n (1 ≤ n ≤ 10^5), which represents the number of comments. Each of the next n lines contains a comment (a non-empty string) that may include zero or more user mentions in the format @handle.

outputFormat

Output a single line to standard output (stdout) containing the most frequently mentioned user handle. If there is a tie, output the lexicographically smallest handle.## sample

1
Hello @alice!
alice

</p>