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