#Lutece2853. 姓名排序

姓名排序

Migrated from Lutece 2853 姓名排序

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

输入若干个人的姓和名,你需要将这些人姓名进行排序。排序的方式如下:

  1. 首先,按照该姓的出现次数排序,即:姓出现次数较多的姓名排在前面。
  2. 其次,若两个人的姓出现的次数一样多(或者是同一个姓),在输入名单中位置较前的排在前面。

Input

输入包括多行,每一行是两个用空格隔开的字符串 sstt,分别表示一个人的姓和名。

Output

输出排序后的姓名名单。

Samples

A A
B B
A C
C E
C G
C F
B D
C E
C G
C F
A A
B B
A C
B D

Constraints

输入只包含大写字母,最多 5000050000 行,每个字符串最多 5050 个字符。

Resources

The 19th UESTC Programming Contest Preliminary