Node = Struct.new(:value, :members, :parent, :left, :right)

n, q = $<.gets.split.map(&:to_i)
table = {}

ai, vi = $<.gets.split.map(&:to_i)
root = Node.new(vi, [ai])
puts "#{ai} #{vi}"
table[ai] = vi

add = ->(num) {
  v = table[num]
  find = ->(node) {
    if v == node.value
      node.members += [num]
    elsif v < node.value
      node.left ? find.(node.left) : node.left = Node.new(v, [num], node) 
    else
      node.right ? find.(node.right) : node.right = Node.new(v, [num], node)
    end
  }
  find.(root)
}

find_max = ->(node) {
  node.right ? find_max.(node.right) : node
}

find = ->(v, node = root) {
  return nil unless node
  if v == node.value
    node
  elsif v < node.value
    find.(v, node.left)
  else
    find.(v, node.right)
  end
}

delete_node = ->(node) {
  if node.left.nil? and node.right.nil?
    if node.parent.right == node
      node.parent.right = nil
    else
      node.parent.left = nil
    end
  elsif node.left and node.right
    max_node = find_max.(node.left)
    node, max_node = max_node, max_node.left
  elsif node.left
    node = node.left
  else
    node = node.right
  end
}

delete = ->(v, person) {
  node = find.(v)
  node.members -= [person]
  delete_node.(node) if node.members.empty?
}

(q - 1).times do
  a, v = $<.gets.split.map(&:to_i)
  tmp = table[a]
  table[a] = 0 unless tmp
  table[a] += v
  add.(a)
  delete.(tmp, a) if tmp
  max_node = find_max.(root)
  puts "#{max_node.members.min} #{max_node.value}"
end

