Prints the k most frequent words in the given input ranked by their frequency. For words with the same frequency rank by alphabet.