from collections import deque

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

ans_time = 0

while len(time)>0:
    tmp_time = time.popleft()
    tmp_name = name.popleft()
    if tmp_time<=q:
        ans_time += tmp_time
        print(tmp_name + " " + str(ans_time))
    else:
        ans_time += q
        time.append(tmp_time-q)
        name.append(tmp_name) from collections import deque n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q name = deque() name deque() deque time = deque() time deque() deque for i in range(n):
    tmp_name, tmp_time = input().split()
    name.append(tmp_name)
    time.append(int(tmp_time)) i range(n) range n tmp_name, tmp_time = input().split() tmp_name input().split() ().split () input split tmp_time name.append(tmp_name) name.append name append tmp_name time.append(int(tmp_time)) time.append time append int(tmp_time) int tmp_time ans_time = 0 ans_time 0 while len(time)>0:
    tmp_time = time.popleft()
    tmp_name = name.popleft()
    if tmp_time<=q:
        ans_time += tmp_time
        print(tmp_name + " " + str(ans_time))
    else:
        ans_time += q
        time.append(tmp_time-q)
        name.append(tmp_name) len(time)>0 len(time) len time 0 tmp_time = time.popleft() tmp_time time.popleft() time.popleft time popleft tmp_name = name.popleft() tmp_name name.popleft() name.popleft name popleft if tmp_time<=q:
        ans_time += tmp_time
        print(tmp_name + " " + str(ans_time))
    else:
        ans_time += q
        time.append(tmp_time-q)
        name.append(tmp_name) tmp_time<=q tmp_time q ans_time += tmp_time ans_time tmp_time print(tmp_name + " " + str(ans_time)) print tmp_name + " " + str(ans_time) tmp_name + " " tmp_name " " str(ans_time) str ans_time ans_time += q ans_time q time.append(tmp_time-q) time.append time append tmp_time-q tmp_time q name.append(tmp_name) name.append name append tmp_name q = map(int, input().split()) map(int, input().split()) q tmp_name, tmp_time = input().split() input().split() tmp_name name = deque() deque() name tmp_name = name.popleft() name.popleft() tmp_name ans_time += tmp_time tmp_time ans_time ans_time += q q ans_time tmp_time = input().split() input().split() tmp_time n, q = map(int, input().split()) map(int, input().split()) n time = deque() deque() time ans_time = 0 0 ans_time tmp_time = time.popleft() time.popleft() tmp_time
from collections import deque

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

ans_time = 0

while len(time)>0:
    tmp_time = time.popleft()
    tmp_name = name.popleft()
    if tmp_time<=q:
        ans_time += tmp_time
        print(tmp_name + " " + str(ans_time))
    else:
        ans_time += q
        time.append(tmp_time-q)
        name.append(tmp_name)