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