t | from collections import defaultdict | t | from collections import defaultdict |
| coloda = defaultdict(set) | | coloda = defaultdict(set) |
| igroki = defaultdict(set) | | igroki = defaultdict(set) |
| while (n := input()): | | while (n := input()): |
| line = n.split(' / ') | | line = n.split(' / ') |
| if len(line) == 2: | | if len(line) == 2: |
| if line[0].isdigit(): | | if line[0].isdigit(): |
| igrok_deck = line[0] | | igrok_deck = line[0] |
| deck_name = line[1] | | deck_name = line[1] |
| coloda[igrok_deck].add(deck_name) | | coloda[igrok_deck].add(deck_name) |
| else: | | else: |
| igrok_name = line[0] | | igrok_name = line[0] |
| igrok_deck = line[1] | | igrok_deck = line[1] |
| igroki[igrok_name].add(igrok_deck) | | igroki[igrok_name].add(igrok_deck) |
| count = defaultdict(int) | | count = defaultdict(int) |
| for igrok, decks in igroki.items(): | | for igrok, decks in igroki.items(): |
| unique_deck = set() | | unique_deck = set() |
| for deck in decks: | | for deck in decks: |
| unique_deck.update(coloda[deck]) | | unique_deck.update(coloda[deck]) |
| count[igrok] = len(unique_deck) | | count[igrok] = len(unique_deck) |
| max_size = max(count.values(), default=0) | | max_size = max(count.values(), default=0) |
| winner = [igrok for igrok, i in count.items() if i == max_size] | | winner = [igrok for igrok, i in count.items() if i == max_size] |
| for igrok in sorted(winner): | | for igrok in sorted(winner): |
| print(igrok) | | print(igrok) |