Read n words, print each unique word with frequency, sorted by frequency descending. Words with the same frequency keep the order in which they first appear.
Write a complete program: read the input with input() and print the result with print().
Input
5
apple
banana
apple
cherry
banana
Output
apple 2
banana 2
cherry 1