n = gets.chomp.to_i
id = []
gain = []
win = {}
tmp = 0
for i in 1..n
a,b = gets.split.map(&:to_i)
id << a
gain << b
if b >= tmp
  tmp = b
end
end
count = 0
for j in gain
if j == tmp
  win[id[count]] = j
end
count += 1
end
result = []
   win.each do |key,value|
  result << key
end
puts [result.min,win[result[0]]].join(" ")
