n | x = dict() | n | card = dict() |
| y = dict() | | player = dict() |
| z = input() | | lst = input() |
| while z: | | while lst: |
| z = z.split('/') | | lst = lst.split('/') |
| if z[0][0:-1].isdigit(): | | if lst[0][0:-1].isdigit(): |
| if z[0][0:-1] in y: | | if lst[0][0:-1] in card: |
| y[z[0][0:-1]] += [z[1][1:]] | | card[lst[0][0:-1]] += [lst[1][1:]] |
| else: | | else: |
n | y[z[0][0:-1]] = [z[1][1:]] | n | card[lst[0][0:-1]] = [lst[1][1:]] |
| else: | | else: |
n | if z[0][0:-1] in x: | n | if lst[0][0:-1] in player: |
| x[z[0][0:-1]] += [z[1][1:]] | | player[lst[0][0:-1]] += [lst[1][1:]] |
| else: | | else: |
t | x[z[0][0:-1]] = [z[1][1:]] | t | player[lst[0][0:-1]] = [lst[1][1:]] |
| z = input() | | lst = input() |
| y_x = dict() | | card_player = dict() |
| for i in x: | | for i in player: |
| y_ig = set() | | card_game = set() |
| for j in x[i]: | | for j in player[i]: |
| y_ig |= set(y[j]) | | card_game |= set(card[j]) |
| y_x[i] = len(y_ig) | | card_player[i] = len(card_game) |
| maxi = max([y_x[i] for i in y_x]) | | maxi = max([card_player[i] for i in card_player]) |
| print(*sorted([i for i in y_x if y_x[i] == maxi]), sep='\n') | | print(*sorted([i for i in card_player if card_player[i] == maxi]), sep='\n') |
| | | |