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

comp = []
t = 0
while queue:
    name, time = queue.popleft()
    if time <= q:
        t += time
        comp.append((name, t))
    else:
        t += q
        queue.append((name, time - q))
for s in comp:
    print(*s) 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 _ in range(n):
    name, time = input().split()
    queue.append((name, int(time))) _ 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 comp = [] comp [] t = 0 t 0 while queue:
    name, time = queue.popleft()
    if time <= q:
        t += time
        comp.append((name, t))
    else:
        t += q
        queue.append((name, time - q)) queue name, time = queue.popleft() name queue.popleft() queue.popleft queue popleft time if time <= q:
        t += time
        comp.append((name, t))
    else:
        t += q
        queue.append((name, time - q)) time <= q time q t += time t time comp.append((name, t)) comp.append comp append (name, t) name t t += q t q queue.append((name, time - q)) queue.append queue append (name, time - q) name time - q time q for s in comp:
    print(*s) s comp print(*s) print *s s name, time = input().split() input().split() name comp = [] [] comp queue = deque() deque() queue t = 0 0 t name, time = queue.popleft() queue.popleft() name time = queue.popleft() queue.popleft() time n, q = map(int, input().split()) map(int, input().split()) n time = input().split() input().split() time q = map(int, input().split()) map(int, input().split()) q t += time time t t += q q t
from collections import deque
n, q = map(int, input().split())
queue = deque()
for _ in range(n):
    name, time = input().split()
    queue.append((name, int(time)))

comp = []
t = 0
while queue:
    name, time = queue.popleft()
    if time <= q:
        t += time
        comp.append((name, t))
    else:
        t += q
        queue.append((name, time - q))
for s in comp:
    print(*s)
