#C11879. Most Frequent Query

    ID: 41243 Type: Default 1000ms 256MiB

Most Frequent Query

Most Frequent Query

You are given an integer \(n\) denoting the number of search queries followed by \(n\) query strings. Your task is to determine the most frequent query among the list. In the event of a tie, return the query that comes first in lexicographical order.

Note: The lexicographical comparison is based on the standard dictionary order. For example, between "apple" and "banana", "apple" is lexicographically smaller.

Example:

Input:
6
apple
banana
apple
orange
banana
apple

Output: apple

</p>

The frequency counts are: apple=3, banana=2, orange=1. Thus, the answer is "apple".

inputFormat

The first line of input contains a single integer \(n\) \( (1 \leq n \leq 10^5)\) representing the number of queries. The following \(n\) lines each contain a query string. Each query string will consist of lowercase English letters only.

outputFormat

Output a single line containing the most frequent query. If multiple queries have the same highest frequency, the one that is lexicographically smallest should be printed.

## sample
6
apple
banana
apple
orange
banana
apple
apple

</p>