f | from collections import * | f | from collections import * |
| owners = defaultdict(list) | | owners = defaultdict(list) |
| cards = defaultdict(list) | | cards = defaultdict(list) |
| d = dict() | | d = dict() |
| res = [] | | res = [] |
| s = input() | | s = input() |
| while s: | | while s: |
| temp = s.split(' / ') | | temp = s.split(' / ') |
t | | t | # if temp[1].isdigit(): |
| | | # owners[temp[0]].append(temp[1]) |
| | | # else: |
| | | # cards[temp[0]].append(temp[1]) |
| if len(temp[0].split(' ')) == 2: | | if len(temp[0].split(' ')) == 2: |
| owners[temp[0]].append(temp[1]) | | owners[temp[0]].append(temp[1]) |
| elif '0' <= temp[1] <= '9': | | elif '0' <= temp[1] <= '9': |
| owners[temp[0]].append(temp[1]) | | owners[temp[0]].append(temp[1]) |
| else: | | else: |
| cards[temp[0]].append(temp[1]) | | cards[temp[0]].append(temp[1]) |
| s = input() | | s = input() |
| | | |
| for k in owners: | | for k in owners: |
| tmp = [] | | tmp = [] |
| for j in owners[k]: | | for j in owners[k]: |
| tmp += cards[j] | | tmp += cards[j] |
| owners[k] = len(set(tmp)) | | owners[k] = len(set(tmp)) |
| | | |
| n = 0 | | n = 0 |
| for k in owners.values(): | | for k in owners.values(): |
| n = k if n < k else n | | n = k if n < k else n |
| for k in owners: | | for k in owners: |
| if owners[k] == n: | | if owners[k] == n: |
| res.append(k) | | res.append(k) |
| res.sort() | | res.sort() |
| for j in res: | | for j in res: |
| print(j) | | print(j) |
| | | |