Sorting words P66705


Statement
 

pdf   zip

html

Given several words, compute the number of appearances of each one. Print first the most common words, and use the lexicographical order to break ties.

Input

Input consists of several cases. Every case begins with a number n between 1 and 104, followed by n words made up only of lowercase letters.

Output

Print the counters and the words in the right order. Print a line with 10 dashes at the end of every case.

Public test cases
  • Input

    6
    z
    anna
    abba
    ivet
    ivet
    anna
    
    3
    hi
    hi
    hi
    

    Output

    2 anna
    2 ivet
    1 abba
    1 z
    ----------
    3 hi
    ----------
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python