n, q = [int(a) for a in input().split()]
total_time = 0
queue = []
for i in range(n):
    queue.append([a for a in input().split()])

while len(queue) > 0:
    name = queue[0][0]
    time = int(queue[0][1])
    if time <= q:
        total_time += time
        print(name + " " + str(total_time))
        del queue[0]
    else:
        total_time += q
        time -= q
        queue.append([name, time])
        del queue[0] int(a) for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() int(a) int a n, q = [int(a) for a in input().split()] n [int(a) for a in input().split()] q total_time = 0 total_time 0 queue = [] queue [] for i in range(n):
    queue.append([a for a in input().split()]) i range(n) range n a for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() a queue.append([a for a in input().split()]) queue.append queue append [a for a in input().split()] while len(queue) > 0:
    name = queue[0][0]
    time = int(queue[0][1])
    if time <= q:
        total_time += time
        print(name + " " + str(total_time))
        del queue[0]
    else:
        total_time += q
        time -= q
        queue.append([name, time])
        del queue[0] len(queue) > 0 len(queue) len queue 0 name = queue[0][0] name queue[0][0] [0] queue 0 0 time = int(queue[0][1]) time int(queue[0][1]) int queue[0][1] [0] queue 0 1 if time <= q:
        total_time += time
        print(name + " " + str(total_time))
        del queue[0]
    else:
        total_time += q
        time -= q
        queue.append([name, time])
        del queue[0] time <= q time q total_time += time total_time time print(name + " " + str(total_time)) print name + " " + str(total_time) name + " " name " " str(total_time) str total_time del queue[0] queue[0] queue 0 total_time += q total_time q time -= q time q queue.append([name, time]) queue.append queue append [name, time] name time del queue[0] queue[0] queue 0 total_time += q q total_time total_time = 0 0 total_time n, q = [int(a) for a in input().split()] [int(a) for a in input().split()] n name = queue[0][0] queue[0][0] name total_time += time time total_time q = [int(a) for a in input().split()] [int(a) for a in input().split()] q time -= q q time time = int(queue[0][1]) int(queue[0][1]) time queue = [] [] queue
n, q = [int(a) for a in input().split()]
total_time = 0
queue = []
for i in range(n):
    queue.append([a for a in input().split()])

while len(queue) > 0:
    name = queue[0][0]
    time = int(queue[0][1])
    if time <= q:
        total_time += time
        print(name + " " + str(total_time))
        del queue[0]
    else:
        total_time += q
        time -= q
        queue.append([name, time])
        del queue[0]
