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

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

result = Array.new
fish = Array.new(n).fill(0)
event.each do |a, v|
  fish[a - 1] += v
  result << [fish.index(fish.max) + 1, fish.max]
end

result.each{|a, v| printf "%d %d\n", a, v}