| f | import time | f | import time | 
            |  |  |  |  | 
            |  | def sort_key(row): |  | def sort_key(row): | 
            |  | return [row[0], row[1][1], row[1][0], row[1][2]] |  | return [row[0], row[1][1], row[1][0], row[1][2]] | 
            | n | str = input().split() | n | inpt = input().split() | 
            |  | curList = [] |  | lst = [] | 
            |  | while str: |  | while inpt: | 
            |  | curList.append([time.strptime(str[-1], '%H:%M:%S'), [str[0], str[1], ' '.join(str[2:len(str) - 1]), str[-1]]]) |  | lst.append([time.strptime(inpt[-1], '%H:%M:%S'), [inpt[0], inpt[1], ' '.join(inpt[2:len(inpt) - 1]), inpt[-1]]]) | 
            |  | str = input().split() |  | inpt = input().split() | 
            |  | curList.sort(reverse=False, key=sort_key) |  | lst.sort(reverse=False, key=sort_key) | 
            |  | res = [curList[0][1]] |  | res = [lst[0][1]] | 
            |  | iCount = 0 |  | cnt = 0 | 
            |  | idx = 0 |  | idx = 0 | 
            | n | while iCount < 3 and idx < len(curList) - 1: | n | while idx < len(lst) - 1 and cnt < 3: | 
            |  | idx += 1 |  | idx += 1 | 
            | t | if curList[idx][0] != curList[idx - 1][0]: | t | if lst[idx][0] != lst[idx - 1][0]: | 
            |  | iCount += 1 |  | cnt += 1 | 
            |  | if iCount < 3: |  | if cnt < 3: | 
            |  | res.append(curList[idx][1]) |  | res.append(lst[idx][1]) | 
            |  | lenMax = [0] * len(res[0]) |  | lengths = [0] * len(res[0]) | 
            |  | for cur in res: |  | for row in res: | 
            |  | for i in range(len(cur)): |  | for i in range(len(row)): | 
            |  | if len(cur[i]) > lenMax[i]: |  | if len(row[i]) > lengths[i]: | 
            |  | lenMax[i] = len(cur[i]) |  | lengths[i] = len(row[i]) | 
            |  | for cur in res: |  | for row in res: | 
            |  | for i in range(len(cur)): |  | for i in range(len(row)): | 
            |  | print('{:<{prec}}'.format(cur[i], prec=lenMax[i]), end=' ') |  | print('{:<{prec}}'.format(row[i], prec=lengths[i]), end=' ') | 
            |  | print() |  | print() |