if __FILE__ == $0
  n, q = gets.split.map{|i| i.to_i}
  wakasagi = Array.new(n, 0)
  q.times do
    a, v = gets.split.map{|i| i.to_i}
    wakasagi[a - 1] += v
    max_wakasagi = wakasagi.max
    max_user = []
    wakasagi.each_with_index do |w, idx|
      if w == max_wakasagi
        max_user << (idx + 1)
      end
    end
    puts "#{ max_user.sort[0] } #{ max_wakasagi }"
  end
end