from collections import deque

n, q = map(int, input().split())
t = 0
queue = deque([])
for _ in range(n):
    name, time = input().split()
    time = int(time)
    queue.append([name, time])
while len(queue):
    if queue[0][1] > q:
        queue[0][1] -= q
        t += q
        queue.rotate(-1)
    else:
        t += queue[0][1]
        queue[0][1] = t
        print(" ".join(list(map(str, queue.popleft())))) from collections import deque n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q t = 0 t 0 queue = deque([]) queue deque([]) deque [] for _ in range(n):
    name, time = input().split()
    time = int(time)
    queue.append([name, time]) _ range(n) range n name, time = input().split() name input().split() ().split () input split time time = int(time) time int(time) int time queue.append([name, time]) queue.append queue append [name, time] name time while len(queue):
    if queue[0][1] > q:
        queue[0][1] -= q
        t += q
        queue.rotate(-1)
    else:
        t += queue[0][1]
        queue[0][1] = t
        print(" ".join(list(map(str, queue.popleft())))) len(queue) len queue if queue[0][1] > q:
        queue[0][1] -= q
        t += q
        queue.rotate(-1)
    else:
        t += queue[0][1]
        queue[0][1] = t
        print(" ".join(list(map(str, queue.popleft())))) queue[0][1] > q queue[0][1] [0] queue 0 1 q queue[0][1] -= q queue[0][1] [0] queue 0 1 q t += q t q queue.rotate(-1) queue.rotate queue rotate -1 t += queue[0][1] t queue[0][1] [0] queue 0 1 queue[0][1] = t queue[0][1] [0] queue 0 1 t print(" ".join(list(map(str, queue.popleft())))) print " ".join(list(map(str, queue.popleft()))) " ".join " " join list(map(str, queue.popleft())) list map(str, queue.popleft()) map str queue.popleft() queue.popleft queue popleft q = map(int, input().split()) map(int, input().split()) q t = 0 0 t n, q = map(int, input().split()) map(int, input().split()) n t += q q t time = int(time) int(time) time queue = deque([]) deque([]) queue name, time = input().split() input().split() name time = input().split() input().split() time t += queue[0][1] queue[0][1] t
from collections import deque

n, q = map(int, input().split())
t = 0
queue = deque([])
for _ in range(n):
    name, time = input().split()
    time = int(time)
    queue.append([name, time])
while len(queue):
    if queue[0][1] > q:
        queue[0][1] -= q
        t += q
        queue.rotate(-1)
    else:
        t += queue[0][1]
        queue[0][1] = t
        print(" ".join(list(map(str, queue.popleft()))))