| 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 | s = input().split() | n | inpt = input().split() | 
             | lst = [] |  | lst = [] | 
            | n | while s: | n | while inpt: | 
             |     lst.append([time.strptime(s[-1], '%H:%M:%S'), [s[0], s[1], ' '.join(s[2:len(s) - 1]), s[-1]]]) |  |     lst.append([time.strptime(inpt[-1], '%H:%M:%S'), [inpt[0], inpt[1], ' '.join(inpt[2:len(inpt) - 1]), inpt[-1]]]) | 
             |     s = input().split() |  |     inpt = input().split() | 
             | lst.sort(reverse=False, key=sort_key) |  | lst.sort(reverse=False, key=sort_key) | 
             | res = [lst[0][1]] |  | res = [lst[0][1]] | 
            | n | counter = 0 | n | cnt = 0 | 
             | index = 0 |  | idx = 0 | 
             | while index < len(lst) - 1 and counter < 3: |  | while idx < len(lst) - 1 and cnt < 3: | 
             |     index += 1 |  |     idx += 1 | 
             |     if lst[index][0] != lst[index - 1][0]: |  |     if lst[idx][0] != lst[idx - 1][0]: | 
             |         counter += 1 |  |         cnt += 1 | 
             |     if counter < 3: |  |     if cnt < 3: | 
             |         res.append(lst[index][1]) |  |         res.append(lst[idx][1]) | 
             | lens = [0] * len(res[0]) |  | lengths = [0] * len(res[0]) | 
             | for row in res: |  | for row in res: | 
             |     for i in range(len(row)): |  |     for i in range(len(row)): | 
            | n |         if len(row[i]) > lens[i]: | n |         if len(row[i]) > lengths[i]: | 
             |             lens[i] = len(row[i]) |  |             lengths[i] = len(row[i]) | 
             | for row in res: |  | for row in res: | 
             |     for i in range(len(row)): |  |     for i in range(len(row)): | 
            | t |         print('{:<{prec}}'.format(row[i], prec=lens[i]), end=' ') | t |         print('{:<{prec}}'.format(row[i], prec=lengths[i]), end=' ') | 
             |     print() |  |     print() |