from collections import deque

n, m = map(int, input().split())
name = ['']*n
time = ['']*n
for i in range(n):
	name[i], time[i] = input().split()
time = list(map(int, time))

Q = deque([i for i in range(n)])
t = 0
while Q!=deque([]):
	q = Q.popleft()
	if time[q]<=m:
		t += time[q]
		print(name[q] + ' ' + str(t))
	else:
		t += m
		time[q] -= m
		Q.append(q) from collections import deque n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m name = ['']*n name ['']*n [''] '' n time = ['']*n time ['']*n [''] '' n for i in range(n):
	name[i], time[i] = input().split() i range(n) range n name[i], time[i] = input().split() name[i] name i input().split() ().split () input split time[i] time i time = list(map(int, time)) time list(map(int, time)) list map(int, time) map int time i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i Q = deque([i for i in range(n)]) Q deque([i for i in range(n)]) deque [i for i in range(n)] t = 0 t 0 while Q!=deque([]):
	q = Q.popleft()
	if time[q]<=m:
		t += time[q]
		print(name[q] + ' ' + str(t))
	else:
		t += m
		time[q] -= m
		Q.append(q) Q!=deque([]) Q deque([]) deque [] q = Q.popleft() q Q.popleft() Q.popleft Q popleft if time[q]<=m:
		t += time[q]
		print(name[q] + ' ' + str(t))
	else:
		t += m
		time[q] -= m
		Q.append(q) time[q]<=m time[q] time q m t += time[q] t time[q] time q print(name[q] + ' ' + str(t)) print name[q] + ' ' + str(t) name[q] + ' ' name[q] name q ' ' str(t) str t t += m t m time[q] -= m time[q] time q m Q.append(q) Q.append Q append q time = list(map(int, time)) list(map(int, time)) time t += time[q] time[q] t name = ['']*n ['']*n name t += m m t t = 0 0 t time = ['']*n ['']*n time q = Q.popleft() Q.popleft() q Q = deque([i for i in range(n)]) deque([i for i in range(n)]) Q n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m
from collections import deque

n, m = map(int, input().split())
name = ['']*n
time = ['']*n
for i in range(n):
	name[i], time[i] = input().split()
time = list(map(int, time))

Q = deque([i for i in range(n)])
t = 0
while Q!=deque([]):
	q = Q.popleft()
	if time[q]<=m:
		t += time[q]
		print(name[q] + ' ' + str(t))
	else:
		t += m
		time[q] -= m
		Q.append(q)
