众所周知,我们seventh自从回家以后异常无聊,于是他就写了一个社交网站,这个网站当然也和别的社交网站一样有添加朋友的功能,但是这个时候seventh想了想,如果社交网站的名字排序按照字典序来,那岂不是太简单了,想到这里,他就设计了一组功能。
· 1. "X posted on Y's wall" (两个人都加15分),
· 2. "X commented on Y's post" (两个人加10分),
· 3. "X likes Y's post" (两个人5加分).
然后当有人执行了以上操作时,系统就会按照分数加上去,最后,按照得出的分数将名字从大到小排序好(分数一样的按字典序排序), 之后展现在列表里的就是你的好友排序(分数为0也要输出,但是自己的名字不能输出);功能设计好了以后seventh突然不想写了,因为他还是觉得太简单,就交给了你们。
The first line contains your name. The second line contains an integer n, which is the number of actions (1 ≤ n ≤ 100). Then n lines follow, it is guaranteed that each one contains exactly 1 action in the format given above. There is exactly one space between each two words in a line, and there are no extra spaces. All the letters are lowercase. All names in the input will consist of at least 1 letter and at most 10 small Latin letters.
第一行输入你的名字,第二行输入m表示有m个(1<=m<=100)个操作,接下来m行是操作类型,一行中两单词间只有一个空格,只有小写字母,名字最多10个最少1个字符。
Print m lines, where m is the number of distinct names in the input (excluding yourself). Each line should contain just 1 name. The names should be sorted according to the priority factor with you in the descending order (the highest priority factor should come first). If two or more names have the same priority factor, print them in the alphabetical (lexicographical) order.
Note, that you should output all the names that are present in the input data (excluding yourself), even if that person has a zero priority factor.
The lexicographical comparison is performed by the standard "<" operator in modern programming languages. The line a is lexicographically smaller than the line b, if either a is the prefix of b, or if exists such an i (1 ≤ i ≤ min(|a|, |b|)), that ai < bi, and for any j (1 ≤ j < i) aj = bj, where |a| and |b| stand for the lengths of strings a and b correspondently.
输出n行,n行是操作里包含的名字(输出不包括自己的名字),按照优先级一个名字一行输出,第一个优先级最高。
ahmed
3
ahmed posted on fatma's wall
fatma commented on ahmed's post
mona likes ahmed's post
fatma
mona
aba
1
likes likes posted's post
likes
posted