if __name__ == '__main__':
n = int(input())
maxScore = 0
minScore = 100
maxRes = ""
minRes = ""
for i in range(n):
inputs = input().split(" ")
if maxScore < int(inputs[2]):
maxScore = int(inputs[2])
maxRes = inputs[0] + " " + inputs[1]
if minScore > int(inputs[2]):
minScore = int(inputs[2])
minRes = inputs[0] + " " + inputs[1]
print(maxRes)
print(minRes)