#coding:utf-8
#1_3_B
n, q = map(int, input().split())
total_time = 0
queue = [input().split() for i in range(n)]

while queue:
    ps = queue.pop(0)
    time = int(ps[1])

    if time <= q:
        total_time += time
        print(ps[0], total_time)
    else:
        total_time += q
        time -= q
        ps[1] = time
        queue.append(ps) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q total_time = 0 total_time 0 input().split() for i in range(n) for i in range(n) i range(n) range n for i in range(n) input().split() ().split () input split queue = [input().split() for i in range(n)] queue [input().split() for i in range(n)] while queue:
    ps = queue.pop(0)
    time = int(ps[1])

    if time <= q:
        total_time += time
        print(ps[0], total_time)
    else:
        total_time += q
        time -= q
        ps[1] = time
        queue.append(ps) queue ps = queue.pop(0) ps queue.pop(0) queue.pop queue pop 0 time = int(ps[1]) time int(ps[1]) int ps[1] ps 1 if time <= q:
        total_time += time
        print(ps[0], total_time)
    else:
        total_time += q
        time -= q
        ps[1] = time
        queue.append(ps) time <= q time q total_time += time total_time time print(ps[0], total_time) print ps[0] ps 0 total_time total_time += q total_time q time -= q time q ps[1] = time ps[1] ps 1 time queue.append(ps) queue.append queue append ps time = int(ps[1]) int(ps[1]) time ps = queue.pop(0) queue.pop(0) ps q = map(int, input().split()) map(int, input().split()) q time -= q q time queue = [input().split() for i in range(n)] [input().split() for i in range(n)] queue n, q = map(int, input().split()) map(int, input().split()) n total_time += q q total_time total_time = 0 0 total_time total_time += time time total_time
#coding:utf-8
#1_3_B
n, q = map(int, input().split())
total_time = 0
queue = [input().split() for i in range(n)]

while queue:
    ps = queue.pop(0)
    time = int(ps[1])

    if time <= q:
        total_time += time
        print(ps[0], total_time)
    else:
        total_time += q
        time -= q
        ps[1] = time
        queue.append(ps)