data = raw_input().split()
n = int(data[0])
q = int(data[1])

queue = []
for i in range(n):
	process = raw_input().split()
	process[1] = int(process[1])
	queue.append(process)

time = 0
while len(queue) > 0:
	if queue[0][1] > q:
		queue[0][1] -= q
		time += q
		queue.append(queue[0])
	else:
		time += queue[0][1]
		print("{:} {:}".format(queue[0][0], time))
	del queue[0] data = raw_input().split() data raw_input().split() ().split () raw_input split n = int(data[0]) n int(data[0]) int data[0] data 0 q = int(data[1]) q int(data[1]) int data[1] data 1 queue = [] queue [] for i in range(n):
	process = raw_input().split()
	process[1] = int(process[1])
	queue.append(process) i range(n) range n process = raw_input().split() process raw_input().split() ().split () raw_input split process[1] = int(process[1]) process[1] process 1 int(process[1]) int process[1] process 1 queue.append(process) queue.append queue append process time = 0 time 0 while len(queue) > 0:
	if queue[0][1] > q:
		queue[0][1] -= q
		time += q
		queue.append(queue[0])
	else:
		time += queue[0][1]
		print("{:} {:}".format(queue[0][0], time))
	del queue[0] len(queue) > 0 len(queue) len queue 0 if queue[0][1] > q:
		queue[0][1] -= q
		time += q
		queue.append(queue[0])
	else:
		time += queue[0][1]
		print("{:} {:}".format(queue[0][0], time))
	 queue[0][1] > q queue[0][1] [0] queue 0 1 q queue[0][1] -= q queue[0][1] [0] queue 0 1 q time += q time q queue.append(queue[0]) queue.append queue append queue[0] queue 0 time += queue[0][1] time queue[0][1] [0] queue 0 1 print("{:} {:}".format(queue[0][0], time)) print "{:} {:}".format(queue[0][0], time) "{:} {:}".format "{:} {:}" format queue[0][0] [0] queue 0 0 time del queue[0] queue[0] queue 0 time += q q time time = 0 0 time q = int(data[1]) int(data[1]) q process = raw_input().split() raw_input().split() process data = raw_input().split() raw_input().split() data n = int(data[0]) int(data[0]) n queue = [] [] queue time += queue[0][1] queue[0][1] time
data = raw_input().split()
n = int(data[0])
q = int(data[1])

queue = []
for i in range(n):
	process = raw_input().split()
	process[1] = int(process[1])
	queue.append(process)

time = 0
while len(queue) > 0:
	if queue[0][1] > q:
		queue[0][1] -= q
		time += q
		queue.append(queue[0])
	else:
		time += queue[0][1]
		print("{:} {:}".format(queue[0][0], time))
	del queue[0]