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

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

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

find_node = ->(val, now = root) {
  return nil unless now
  if val == now.value
    now
  elsif val < now.value
    find_node.(val, now.left)
  else
    find_node.(val, now.right)
  end
}

add_node = ->(val, added) {
  find = ->(node, parent, f = nil) {
    if node
      if val < node.value
        find.(node.left, node, 0)
      else
        find.(node.right, node, 1)
      end
    else
      added.parent = parent
      f.zero? ? parent.left = added : parent.right = added
    end
  }
  find.(root, nil)
}

add = ->(num) {
  v = fish_num[num]
  node = find_node.(v)
  if node
    node.members += [num]
  else
    add_node.(v, Node.new(v, [num]))
  end
}

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

replace = ->(node, replaced) {
  if node.parent.right == node
    node.parent.right = replaced
  else
    node.parent.left = replaced
  end
}

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

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

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

