n, q = $stdin.gets.chomp.split(" ").map(&:to_i)
fish = Array.new
q.times do
  a, v = $stdin.gets.chomp.split(" ").map(&:to_i)
  if data = fish.select{|sa, sv| sa == a}[0]
    data[1] += v
  else
    fish << [a, v]
  end
  fish.sort!{|f1, f2| f2[1] <=> f1[1]}
    printf "%d %d\n", fish[0][0], fish[0][1]
end