n,q = [int(s) for s in input().split()]
queue = []
for i in range(n):
	name,time = input().split()
	queue.append([name,int(time)])

time = 0
while queue:
	processing = queue.pop(0)
	t = min(processing[1], q)
	time += t
	processing[1] -= t
	if processing[1] == 0:
		print(processing[0],time)
	else:
		queue.append(processing) int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s n,q = [int(s) for s in input().split()] n [int(s) for s in input().split()] q queue = [] queue [] for i in range(n):
	name,time = input().split()
	queue.append([name,int(time)]) i range(n) range n name,time = input().split() name input().split() ().split () input split time queue.append([name,int(time)]) queue.append queue append [name,int(time)] name int(time) int time time = 0 time 0 while queue:
	processing = queue.pop(0)
	t = min(processing[1], q)
	time += t
	processing[1] -= t
	if processing[1] == 0:
		print(processing[0],time)
	else:
		queue.append(processing) queue processing = queue.pop(0) processing queue.pop(0) queue.pop queue pop 0 t = min(processing[1], q) t min(processing[1], q) min processing[1] processing 1 q time += t time t processing[1] -= t processing[1] processing 1 t if processing[1] == 0:
		print(processing[0],time)
	else:
		queue.append(processing) processing[1] == 0 processing[1] processing 1 0 print(processing[0],time) print processing[0] processing 0 time queue.append(processing) queue.append queue append processing n,q = [int(s) for s in input().split()] [int(s) for s in input().split()] n q = [int(s) for s in input().split()] [int(s) for s in input().split()] q name,time = input().split() input().split() name queue = [] [] queue time = input().split() input().split() time time += t t time time = 0 0 time t = min(processing[1], q) min(processing[1], q) t processing = queue.pop(0) queue.pop(0) processing
n,q = [int(s) for s in input().split()]
queue = []
for i in range(n):
	name,time = input().split()
	queue.append([name,int(time)])

time = 0
while queue:
	processing = queue.pop(0)
	t = min(processing[1], q)
	time += t
	processing[1] -= t
	if processing[1] == 0:
		print(processing[0],time)
	else:
		queue.append(processing)