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