Read from standard input a non-negative integer n, followed by n pairs each consisting of a word (no spaces, letters only) and a non-negative integer representing the frequency of that word. Print the n pairs in decreasing order of frequency. For equal frequencies, use lexicographically increasing order of the words.
Data is read from standard input (in the format described), not from a file.