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