a = raw_input()
n, q = a.split(" ")
n = int(n)
q = int(q)
total = 0

queue = []
for i in range(n):
	queue.append(raw_input())
while (len(queue) > 0):
	b = queue.pop(0)
	p, t = b.split(" ")
	sa = int(t) - q
	if sa > 0:
		queue.append(p + " " + str(sa))
		total += q
	else:
		total += int(t)
		print (p + " " + str(total)) a = raw_input() a raw_input() raw_input n, q = a.split(" ") n a.split(" ") a.split a split " " q n = int(n) n int(n) int n q = int(q) q int(q) int q total = 0 total 0 queue = [] queue [] for i in range(n):
	queue.append(raw_input()) i range(n) range n queue.append(raw_input()) queue.append queue append raw_input() raw_input while (len(queue) > 0):
	b = queue.pop(0)
	p, t = b.split(" ")
	sa = int(t) - q
	if sa > 0:
		queue.append(p + " " + str(sa))
		total += q
	else:
		total += int(t)
		print (p + " " + str(total)) len(queue) > 0 len(queue) len queue 0 b = queue.pop(0) b queue.pop(0) queue.pop queue pop 0 p, t = b.split(" ") p b.split(" ") b.split b split " " t sa = int(t) - q sa int(t) - q int(t) int t q if sa > 0:
		queue.append(p + " " + str(sa))
		total += q
	else:
		total += int(t)
		print (p + " " + str(total)) sa > 0 sa 0 queue.append(p + " " + str(sa)) queue.append queue append p + " " + str(sa) p + " " p " " str(sa) str sa total += q total q total += int(t) total int(t) int t print (p + " " + str(total)) print p + " " + str(total) p + " " p " " str(total) str total a = raw_input() raw_input() a t = b.split(" ") b.split(" ") t b = queue.pop(0) queue.pop(0) b total = 0 0 total sa = int(t) - q int(t) - q sa queue = [] [] queue q = a.split(" ") a.split(" ") q p, t = b.split(" ") b.split(" ") p total += int(t) int(t) total n, q = a.split(" ") a.split(" ") n n = int(n) int(n) n q = int(q) int(q) q total += q q total
a = raw_input()
n, q = a.split(" ")
n = int(n)
q = int(q)
total = 0

queue = []
for i in range(n):
	queue.append(raw_input())
while (len(queue) > 0):
	b = queue.pop(0)
	p, t = b.split(" ")
	sa = int(t) - q
	if sa > 0:
		queue.append(p + " " + str(sa))
		total += q
	else:
		total += int(t)
		print (p + " " + str(total))