Hubble is a link sharing website for IITR students. It wants to add a new feature called Trending4U. This feature sorts all the links posted from IITR janta according to the importance factor. This importance factor is affected by three types of actions: 1. "A shared on B's link" (30 points), 2. "A commented on B's link" (20 points), 3. "A likes B's link" (10 points).
A and B are two distinct names. And each action increases the importance factor between A and B (and vice versa) by the above value of points (the importance factor between A and B is the same as the importance factor between B and A). You will be given n actions without the action number and points, and you have to print all the distinct names in these actions sorted according to the importance factor with you.
INPUT: 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, each containing exactly one action in the above format. 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 are small (1<= length <= 10) .
OUTPUT: Print l lines, where l is the number of distinct names in the input (excluding yourself) with each line having exactly 1 name. The names should be sorted according to the importance 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.
Input: aps 3 aps shared on divij's link divij commented on aps's link kandoi likes aps's link
Output: divij kandoi
Input: xyz 1 sopan likes vampire's link
Output: sopan vampire ( NOTE: " ' " symbol used here shouldn't be copied as it may not be the same symbol as the usual "apostrophe" )