#C13251. Most Frequent Word

    ID: 42769 Type: Default 1000ms 256MiB

Most Frequent Word

Most Frequent Word

You are given a list of words. Your task is to find the word that appears most frequently in the list. In case of a tie, choose the word that appears first in the order of appearance.

Formally, if the list of words is \(A = [a_1, a_2, \dots, a_n]\), let \(f(w)\) denote the frequency of word \(w\) in \(A\). You should output the word \(w\) such that \(f(w)\) is maximized. If there exist multiple words with the same maximum frequency, choose the one with the smallest index of first occurrence in \(A\). If the list is empty, output None.

inputFormat

The first line of input is an integer \(n\) representing the number of words. The next \(n\) lines each contain one word.

If \(n = 0\), then the list is empty and you should output None.

outputFormat

Output the word with the highest frequency. In case of a tie, output the word that appears first among those with the highest frequency. If the list is empty, output None.

## sample
6
apple
banana
apple
orange
banana
apple
apple