#C9958. Most Frequent Item

    ID: 54108 Type: Default 1000ms 256MiB

Most Frequent Item

Most Frequent Item

You are given a list of items from a store, each represented as a string. Some items may occur multiple times. Your task is to determine the item that appears most frequently. In the event of a tie, output the item that is lexicographically smallest (i.e. appears earlier in alphabetical order). If the list is empty, output an empty string.

The problem can be formulated mathematically as:

Let \( A = [a_1, a_2, \dots, a_n] \) be the list of items. Find an item \( x \) such that

\( x = \min\{ y \;|\; count(y) = \max_{z \in A} count(z) \} \), where \( count(y) \) is the number of occurrences of \( y \).

inputFormat

The first line of input contains an integer \( n \) representing the number of items. The next \( n \) lines each contain a single string denoting an item. If \( n = 0 \), it indicates that the list is empty.

outputFormat

Output the item that appears most frequently. In case of a tie, output the lexicographically smallest item. If the list is empty, output an empty string.

## sample
1
apple
apple

</p>