fish = Hash.new(0)
max = 0
max_fishers = []
selected_fisher = nil

n, q = $<.gets.split.map(&:to_i)
q.times do
  a, v = $<.gets.split.map(&:to_i)
  fish[a] += v
  if v > 0
    if fish[a] > max
      max = fish[a]
      puts "#{a} #{max}"
      max_fishers = [a]
      selected_fisher = a
    elsif fish[a] == max
      max_fishers << a
      puts "#{selected_fisher = max_fishers.min} #{max}"
    else
      puts "#{selected_fisher} #{max}"
    end
  else
    if fish[a] - v == max
      if max_fishers.size == 1
        max = fish.values.max
        max_fishers = fish.keys.select {|k| fish[k] == max}
        puts "#{selected_fisher = max_fishers.min} #{max}"
      else
        max_fishers.delete(a)
        puts "#{selected_fisher = max_fishers.min} #{max}"
      end
    else
      puts "#{selected_fisher} #{max}"
    end
  end
end

