import collections
n,q = map(int, input().split())
queue = collections.deque(maxlen=100000)

for i in range(n):
    p,t = input().split()
    queue.append([p, int(t)])

time = 0
while queue:
    p,t = queue.popleft()
    if t<=q:
        time += t
        print(p,time)
    else:
        time += q
        queue.append([p,t-q]) import collections collections n,q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q queue = collections.deque(maxlen=100000) queue collections.deque(maxlen=100000) collections.deque collections deque maxlen=100000 maxlen 100000 for i in range(n):
    p,t = input().split()
    queue.append([p, int(t)]) i range(n) range n p,t = input().split() p input().split() ().split () input split t queue.append([p, int(t)]) queue.append queue append [p, int(t)] p int(t) int t time = 0 time 0 while queue:
    p,t = queue.popleft()
    if t<=q:
        time += t
        print(p,time)
    else:
        time += q
        queue.append([p,t-q]) queue p,t = queue.popleft() p queue.popleft() queue.popleft queue popleft t if t<=q:
        time += t
        print(p,time)
    else:
        time += q
        queue.append([p,t-q]) t<=q t q time += t time t print(p,time) print p time time += q time q queue.append([p,t-q]) queue.append queue append [p,t-q] p t-q t q queue = collections.deque(maxlen=100000) collections.deque(maxlen=100000) queue time += q q time t = queue.popleft() queue.popleft() t n,q = map(int, input().split()) map(int, input().split()) n q = map(int, input().split()) map(int, input().split()) q time = 0 0 time time += t t time t = input().split() input().split() t p,t = queue.popleft() queue.popleft() p p,t = input().split() input().split() p
import collections
n,q = map(int, input().split())
queue = collections.deque(maxlen=100000)

for i in range(n):
    p,t = input().split()
    queue.append([p, int(t)])

time = 0
while queue:
    p,t = queue.popleft()
    if t<=q:
        time += t
        print(p,time)
    else:
        time += q
        queue.append([p,t-q])