Mode

Write a program that finds the most frequent word for every given sequence of words.

Input

Input consists of several cases. Every case begins with a number nn between 1 and 10510^5, followed by nn words made up of only lowercase letters. A special case with n=0n = 0 marks the end of input.

Output

For every case, print the word that appears more times. If there is a tie, print the largest word in alphabetical order.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:09:14.523Z

© Jutge.org, 2006–2026.
https://jutge.org