import sys
from collections import deque

n,q = map(int,input().split())
f = lambda n,t: (n,int(t))
queue = deque(f(*l.split()) for l in sys.stdin)

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

n,q = map(int,input().split())
f = lambda n,t: (n,int(t))
queue = deque(f(*l.split()) for l in sys.stdin)

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