class Task
	
	def initialize(name, qms)
		@name = name
		if !qms.is_a? Integer
			qms = qms.to_i
		end
		@qms = qms
	end

	def consume(time)
		@qms -= time
	end

	def to_s
		"#{@name}"
	end

end

n, consume_time = STDIN.gets.split.map(&:to_i)
queue = []
n.times do
	pname, ptime = STDIN.gets.split
	queue.push(Task.new(pname, ptime))
end

past_time = 0
until queue.empty?
	task = queue.shift
	remain = task.consume(consume_time)

	if remain > 0
		past_time += 100
		queue.push(task)
	else
		past_time += consume_time + remain # remainはマイナスなので
		puts "#{task.to_s} #{past_time}"
	end
end