import collections as cols

n, q = [int(x) for x in input().split()]
qu = cols.deque()

for i in range(n):
	tmp = [x for x in input().split()]
	qu.append([tmp[0], int(tmp[1])])

num = n
t = 0

while num > 0:
	tmp = qu.popleft()
	if tmp[1] > q:
		t += q
		qu.append([tmp[0], tmp[1] - q])
	else:
		t += tmp[1]
		num -= 1
		print(tmp[0], t) import collections as cols collections int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n, q = [int(x) for x in input().split()] n [int(x) for x in input().split()] q qu = cols.deque() qu cols.deque() cols.deque cols deque for i in range(n):
	tmp = [x for x in input().split()]
	qu.append([tmp[0], int(tmp[1])]) i range(n) range n x for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() x tmp = [x for x in input().split()] tmp [x for x in input().split()] qu.append([tmp[0], int(tmp[1])]) qu.append qu append [tmp[0], int(tmp[1])] tmp[0] tmp 0 int(tmp[1]) int tmp[1] tmp 1 num = n num n t = 0 t 0 while num > 0:
	tmp = qu.popleft()
	if tmp[1] > q:
		t += q
		qu.append([tmp[0], tmp[1] - q])
	else:
		t += tmp[1]
		num -= 1
		print(tmp[0], t) num > 0 num 0 tmp = qu.popleft() tmp qu.popleft() qu.popleft qu popleft if tmp[1] > q:
		t += q
		qu.append([tmp[0], tmp[1] - q])
	else:
		t += tmp[1]
		num -= 1
		print(tmp[0], t) tmp[1] > q tmp[1] tmp 1 q t += q t q qu.append([tmp[0], tmp[1] - q]) qu.append qu append [tmp[0], tmp[1] - q] tmp[0] tmp 0 tmp[1] - q tmp[1] tmp 1 q t += tmp[1] t tmp[1] tmp 1 num -= 1 num 1 print(tmp[0], t) print tmp[0] tmp 0 t num = n n num t = 0 0 t q = [int(x) for x in input().split()] [int(x) for x in input().split()] q t += tmp[1] tmp[1] t num -= 1 1 num qu = cols.deque() cols.deque() qu tmp = qu.popleft() qu.popleft() tmp tmp = [x for x in input().split()] [x for x in input().split()] tmp n, q = [int(x) for x in input().split()] [int(x) for x in input().split()] n t += q q t
import collections as cols

n, q = [int(x) for x in input().split()]
qu = cols.deque()

for i in range(n):
	tmp = [x for x in input().split()]
	qu.append([tmp[0], int(tmp[1])])

num = n
t = 0

while num > 0:
	tmp = qu.popleft()
	if tmp[1] > q:
		t += q
		qu.append([tmp[0], tmp[1] - q])
	else:
		t += tmp[1]
		num -= 1
		print(tmp[0], t)