연도를 기준으로 1차 정렬, 월을 기준으로 2차 정렬, 일을 기준으로 3차 정렬을 하면 맨 처음 나오는 요소는 가장 나이가 많은 사람이 되고 맨 마지막에 나오는 요소는 가장 나이가 적은 사람이 된다.
import sys
n = int(input())
student = []
for _ in range(n):
name, day, month, year = map(str, sys.stdin.readline().strip().split())
day = int(day)
month = int(month)
year = int(year)
student.append([name, day, month, year])
student.sort(key = lambda x : (x[3], x[2], x[1]))
print(student[n-1][0])
print(student[0][0])