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

t = 0
while queue:
	name,time = queue.pop(0)
	t += min(q, time)
	if time > q:
		queue.append((name, time-q))
	else:
		print(name,t) n,q = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () 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 t = 0 t 0 while queue:
	name,time = queue.pop(0)
	t += min(q, time)
	if time > q:
		queue.append((name, time-q))
	else:
		print(name,t) queue name,time = queue.pop(0) name queue.pop(0) queue.pop queue pop 0 time t += min(q, time) t min(q, time) min q time if time > q:
		queue.append((name, time-q))
	else:
		print(name,t) time > q time q queue.append((name, time-q)) queue.append queue append (name, time-q) name time-q time q print(name,t) print name t n,q = map(int,input().split()) map(int,input().split()) n q = map(int,input().split()) map(int,input().split()) q name,time = input().split() input().split() name t = 0 0 t name,time = queue.pop(0) queue.pop(0) name queue = [] [] queue time = queue.pop(0) queue.pop(0) time t += min(q, time) min(q, time) t time = input().split() input().split() time
n,q = map(int,input().split())
queue = []
for i in range(n):
	name,time = input().split()
	queue.append((name, int(time)))

t = 0
while queue:
	name,time = queue.pop(0)
	t += min(q, time)
	if time > q:
		queue.append((name, time-q))
	else:
		print(name,t)
