2214: 学校图书馆

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:25 Solved:11

Description

学校图书馆记录了一个月内所有图书的借阅情况。每条记录是一本书的书名。请你统计每本书被借阅的次数,然后按借阅次数从多到少排序输出借阅排行榜。如果次数相同,按书名字典序排列。

Input

第一行:一个整数 n(借阅记录数,n ≤ 10000)
接下来 n 行:每行一个字符串(书名,含空格,长度 ≤ 50)


Output

按借阅次数从多到少输出,每行格式:书名 借阅次数。次数相同的按书名字典序排列。

Sample Input Copy

7
Harry Potter
Math Book
Harry Potter
English Book
Math Book
Harry Potter
English Book

Sample Output Copy

Harry Potter 3
English ook 2
Math Book 2

HINT

1<n<10000; (书名含空格,长度 ≤ 50)