#!/usr/bin/ruby -Ku

require 'pp'

n = gets.split(nil)[0].to_i

rec = Hash.new

n.times{
  data = gets.split(nil)
  num, fish = data
  if rec.include?(fish) then
    rec[fish] = [rec[fish], num.to_i].min
  else
    rec[fish] = num.to_i
  end
}

b = rec.sort.reverse[0]
puts "#{b[1]} #{b[0]}"