from collections import deque

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

t = 0
while queue:
	name,time = queue.popleft()
	t += min(q, time)
	if time > q:
		queue.append((name, time-q))
	else:
		print(name,t) from collections import deque n,q = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split q queue = deque() queue deque() deque 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.popleft()
	t += min(q, time)
	if time > q:
		queue.append((name, time-q))
	else:
		print(name,t) queue name,time = queue.popleft() name queue.popleft() queue.popleft queue popleft 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 queue = deque() deque() queue t += min(q, time) min(q, time) t q = map(int,input().split()) map(int,input().split()) q n,q = map(int,input().split()) map(int,input().split()) n time = queue.popleft() queue.popleft() time name,time = queue.popleft() queue.popleft() name name,time = input().split() input().split() name time = input().split() input().split() time t = 0 0 t
from collections import deque

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

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