Mode P86534


Statement
 

pdf   zip

thehtml

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 n between 1 and 105, followed by n words made up of only lowercase letters. A special case with n = 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.

Public test cases
  • Input

    6 joan maria maria anna maria joan
    2 aaa b
    0
    

    Output

    maria
    b
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C++