Problem Description

Read n words and integer k. Output top k words by frequency (desc), tie by word (asc).

Input Format

First line n k. Next n lines: word.

Output Format

k lines: word count.

Sample Test Case

Input:
7 2 bat apple bat cat apple bat cat
Output:
bat 3 apple 2

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next