n,q = map(int,input().split())
queue = []
for i in range(n):
    p,t = map(str,(input().split()))
    t = int(t)
    queue.append([p,t])

total_time = 0
while len(queue)  > 0:
    x = queue.pop(0)
    if x[1] > q :
        total_time += q
        x[1] -= q
        queue.append(x)
    else:
        total_time += x[1]
        print(x[0],total_time) n,q = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split q queue = [] queue [] for i in range(n):
    p,t = map(str,(input().split()))
    t = int(t)
    queue.append([p,t]) i range(n) range n p,t = map(str,(input().split())) p map(str,(input().split())) map str input().split() ().split () input split t t = int(t) t int(t) int t queue.append([p,t]) queue.append queue append [p,t] p t total_time = 0 total_time 0 while len(queue)  > 0:
    x = queue.pop(0)
    if x[1] > q :
        total_time += q
        x[1] -= q
        queue.append(x)
    else:
        total_time += x[1]
        print(x[0],total_time) len(queue)  > 0 len(queue) len queue 0 x = queue.pop(0) x queue.pop(0) queue.pop queue pop 0 if x[1] > q :
        total_time += q
        x[1] -= q
        queue.append(x)
    else:
        total_time += x[1]
        print(x[0],total_time) x[1] > q x[1] x 1 q total_time += q total_time q x[1] -= q x[1] x 1 q queue.append(x) queue.append queue append x total_time += x[1] total_time x[1] x 1 print(x[0],total_time) print x[0] x 0 total_time n,q = map(int,input().split()) map(int,input().split()) n total_time += q q total_time q = map(int,input().split()) map(int,input().split()) q total_time = 0 0 total_time p,t = map(str,(input().split())) map(str,(input().split())) p t = map(str,(input().split())) map(str,(input().split())) t total_time += x[1] x[1] total_time t = int(t) int(t) t x = queue.pop(0) queue.pop(0) x queue = [] [] queue
n,q = map(int,input().split())
queue = []
for i in range(n):
    p,t = map(str,(input().split()))
    t = int(t)
    queue.append([p,t])

total_time = 0
while len(queue)  > 0:
    x = queue.pop(0)
    if x[1] > q :
        total_time += q
        x[1] -= q
        queue.append(x)
    else:
        total_time += x[1]
        print(x[0],total_time)