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

fish = Array.new(n).fill(0)
q.times do
  a, v = $stdin.gets.chomp.split(" ").map(&:to_i)
  fish[a - 1] += v
  printf "%d %d\n", fish.index(fish.max) + 1, fish.max
end