n, q = $stdin.gets.chomp.split(" ").map(&:to_i)

data = Array.new
q.times do
  data << $stdin.gets.chomp.split(" ").map(&:to_i)
end

fish = Array.new(n).fill(0)
data.each do |a, v|
  fish[a - 1] += v
end

printf "%d %d\n", fish.index(fish.max) + 1, fish.max