from collections import deque

n, qt = map(int, input().split())
que = deque()
for i in range(n):
    name, time = input().split()
    que.append((name, int(time)))

elapsedtime = 0
while que:
    name, time = que.popleft()
    if time <= qt:
        elapsedtime += time
        print(name, elapsedtime)
    else:
        elapsedtime += qt
        time -= qt
        que.append((name, time)) from collections import deque n, qt = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split qt que = deque() que deque() deque for i in range(n):
    name, time = input().split()
    que.append((name, int(time))) i range(n) range n name, time = input().split() name input().split() ().split () input split time que.append((name, int(time))) que.append que append (name, int(time)) name int(time) int time elapsedtime = 0 elapsedtime 0 while que:
    name, time = que.popleft()
    if time <= qt:
        elapsedtime += time
        print(name, elapsedtime)
    else:
        elapsedtime += qt
        time -= qt
        que.append((name, time)) que name, time = que.popleft() name que.popleft() que.popleft que popleft time if time <= qt:
        elapsedtime += time
        print(name, elapsedtime)
    else:
        elapsedtime += qt
        time -= qt
        que.append((name, time)) time <= qt time qt elapsedtime += time elapsedtime time print(name, elapsedtime) print name elapsedtime elapsedtime += qt elapsedtime qt time -= qt time qt que.append((name, time)) que.append que append (name, time) name time elapsedtime += time time elapsedtime elapsedtime = 0 0 elapsedtime n, qt = map(int, input().split()) map(int, input().split()) n time = input().split() input().split() time name, time = input().split() input().split() name name, time = que.popleft() que.popleft() name time = que.popleft() que.popleft() time time -= qt qt time qt = map(int, input().split()) map(int, input().split()) qt que = deque() deque() que elapsedtime += qt qt elapsedtime
from collections import deque

n, qt = map(int, input().split())
que = deque()
for i in range(n):
    name, time = input().split()
    que.append((name, int(time)))

elapsedtime = 0
while que:
    name, time = que.popleft()
    if time <= qt:
        elapsedtime += time
        print(name, elapsedtime)
    else:
        elapsedtime += qt
        time -= qt
        que.append((name, time))