| n |  | n | x = dict() | 
             | player = dict() |  | y = dict() | 
             | card = 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 card: |  |         if z[0][0:-1] in y: | 
             |             card[spis[0][0:-1]] += [spis[1][1:]] |  |             y[z[0][0:-1]] += [z[1][1:]] | 
             |         else: |  |         else: | 
            | n |             card[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 player: | n |         if z[0][0:-1] in x: | 
             |             player[spis[0][0:-1]] += [spis[1][1:]] |  |             x[z[0][0:-1]] += [z[1][1:]] | 
             |         else: |  |         else: | 
            | t |             player[spis[0][0:-1]] = [spis[1][1:]] | t |             x[z[0][0:-1]] = [z[1][1:]] | 
             |     spis = input() |  |     z = input() | 
             | playerCard = dict() |  | y_x = dict() | 
             | for i in player: |  | for i in x: | 
             |     cardP = set() |  |     y_ig = set() | 
             |     for j in player[i]: |  |     for j in x[i]: | 
             |         cardP |= set(card[j]) |  |         y_ig |= set(y[j]) | 
             |     playerCard[i] = len(cardP) |  |     y_x[i] = len(y_ig) | 
             | maxP = max([playerCard[i] for i in playerCard]) |  | maxi = max([y_x[i] for i in y_x]) | 
             | print(*sorted([i for i in playerCard if playerCard[i] == maxP]), sep='\n') |  | print(*sorted([i for i in y_x if y_x[i] == maxi]), sep='\n') | 
             |  |  |  |