| n | line = input() | n | inp = input() | 
             | uch = dict() |  | person = dict() | 
             | colod = dict() |  | colod = dict() | 
            | n | while line != '': | n | while inp != '': | 
             |     mas = line.split(' / ') |  |     mas = inp.split(' / ') | 
             |     if mas[0].isdigit(): |  |     if mas[0].isdigit(): | 
            | n |         if not(mas[0] in colod): | n |         if not (mas[0] in colod): | 
             |             colod[mas[0]] = set() |  |             colod[mas[0]] = set() | 
             |         colod[mas[0]].add(mas[1]) |  |         colod[mas[0]].add(mas[1]) | 
             |     else: |  |     else: | 
            | n |         if not(mas[0] in uch): | n |         if not (mas[0] in person): | 
             |             uch[mas[0]] = set() |  |             person[mas[0]] = set() | 
             |         uch[mas[0]].add(mas[1]) |  |         person[mas[0]].add(mas[1]) | 
             |     line = input() |  |     inp = input() | 
             |  |  |   | 
             | res = dict() |  | res = dict() | 
            | n | for i in uch: | n | for i in person: | 
             |     res[i] = 0 |  |     res[i] = 0 | 
             |     a = set() |  |     a = set() | 
            | n |     for j in uch[i]: | n |     for j in person[i]: | 
             |         # print(colod[j]) |  |  | 
             |         a.update(colod[j]) |  |         a.update(colod[j]) | 
             |     res[i] = len(a) |  |     res[i] = len(a) | 
            | n |  | n |   | 
             | list_d = list(res.items()) |  | list_d = list(res.items()) | 
             | list_d.sort(key=lambda i: (i[1], i[0])) |  | list_d.sort(key=lambda i: (i[1], i[0])) | 
             | n = 0 |  | n = 0 | 
            | n | # for i in list_d: | n |  | 
             | #               print( i[0], i[1]) |  |  | 
             | i = 1 |  | i = 1 | 
             | num = list_d[-1][1] |  | num = list_d[-1][1] | 
            | n | while i <= len(list_d) and (num == (list_d[-i][1]) or (i == 1)): | n | while i <= len(list_d) and (num == list_d[-i][1] or i == 1): | 
             |     # print(list_d[-i][0]) |  |  | 
             |     n += 1 |  |     n += 1 | 
             |     i += 1 |  |     i += 1 | 
            | n |  | n |   | 
             | num = n |  | num = n | 
             | i = 0 |  | i = 0 | 
            | t | while (num > 0): | t | while num > 0: | 
             |     print(list_d[-n+i][0]) |  |     print(list_d[-n+i][0]) | 
             |     i += 1 |  |     i += 1 | 
             |     num -= 1 |  |     num -= 1 | 
             |  |  |  |