class Queue:
    queue_list = []
    def enqueue(self, a):
        self.queue_list.append(a)
    def dequeue(self):
        return self.queue_list.pop(0)
    def isEmpty(self):
        return len(self.queue_list) == 0

n, q = list(map(lambda x: int(x), input().strip().split()))

queue = Queue()

for i in range(n):
    queue.enqueue(input().strip().split())


sum_time = 0
while not queue.isEmpty():
    name, time = queue.dequeue()
    if int(time) <= q:
        sum_time += int(time)
        print(name + ' ' + str(sum_time))
    else:
        queue.enqueue([name, str(int(time) - q)])
        sum_time += q
 class Queue:
    queue_list = []
    def enqueue(self, a):
        self.queue_list.append(a)
    def dequeue(self):
        return self.queue_list.pop(0)
    def isEmpty(self):
        return len(self.queue_list) == 0 Queue queue_list = [] queue_list [] def enqueue(self, a):
        self.queue_list.append(a)
     enqueue self.queue_list.append(a) self.queue_list.append self.queue_list self queue_list append a self self a a def dequeue(self):
        return self.queue_list.pop(0)
     dequeue return self.queue_list.pop(0) self.queue_list.pop(0) self.queue_list.pop self.queue_list self queue_list pop 0 self self def isEmpty(self):
        return len(self.queue_list) == 0 isEmpty return len(self.queue_list) == 0 len(self.queue_list) == 0 len(self.queue_list) len self.queue_list self queue_list 0 self self n, q = list(map(lambda x: int(x), input().strip().split())) n list(map(lambda x: int(x), input().strip().split())) list map(lambda x: int(x), input().strip().split()) map lambda x: int(x) int(x) int x x input().strip().split() ().strip().split ().strip() ().strip () input strip split q queue = Queue() queue Queue() Queue for i in range(n):
    queue.enqueue(input().strip().split()) i range(n) range n queue.enqueue(input().strip().split()) queue.enqueue queue enqueue input().strip().split() ().strip().split ().strip() ().strip () input strip split sum_time = 0 sum_time 0 while not queue.isEmpty():
    name, time = queue.dequeue()
    if int(time) <= q:
        sum_time += int(time)
        print(name + ' ' + str(sum_time))
    else:
        queue.enqueue([name, str(int(time) - q)])
        sum_time += q not queue.isEmpty() queue.isEmpty() queue.isEmpty queue isEmpty name, time = queue.dequeue() name queue.dequeue() queue.dequeue queue dequeue time if int(time) <= q:
        sum_time += int(time)
        print(name + ' ' + str(sum_time))
    else:
        queue.enqueue([name, str(int(time) - q)])
        sum_time += q int(time) <= q int(time) int time q sum_time += int(time) sum_time int(time) int time print(name + ' ' + str(sum_time)) print name + ' ' + str(sum_time) name + ' ' name ' ' str(sum_time) str sum_time queue.enqueue([name, str(int(time) - q)]) queue.enqueue queue enqueue [name, str(int(time) - q)] name str(int(time) - q) str int(time) - q int(time) int time q sum_time += q sum_time q class Queue:
    queue_list = []
    def enqueue(self, a):
        self.queue_list.append(a)
    def dequeue(self):
        return self.queue_list.pop(0)
    def isEmpty(self):
        return len(self.queue_list) == 0 class Queue:
    queue_list = []
    def enqueue(self, a):
        self.queue_list.append(a)
    def dequeue(self):
        return self.queue_list.pop(0)
    def isEmpty(self):
        return len(self.queue_list) == 0 Queue q = list(map(lambda x: int(x), input().strip().split())) list(map(lambda x: int(x), input().strip().split())) q queue = Queue() Queue() queue sum_time += q q sum_time name, time = queue.dequeue() queue.dequeue() name time = queue.dequeue() queue.dequeue() time sum_time = 0 0 sum_time n, q = list(map(lambda x: int(x), input().strip().split())) list(map(lambda x: int(x), input().strip().split())) n sum_time += int(time) int(time) sum_time
class Queue:
    queue_list = []
    def enqueue(self, a):
        self.queue_list.append(a)
    def dequeue(self):
        return self.queue_list.pop(0)
    def isEmpty(self):
        return len(self.queue_list) == 0

n, q = list(map(lambda x: int(x), input().strip().split()))

queue = Queue()

for i in range(n):
    queue.enqueue(input().strip().split())


sum_time = 0
while not queue.isEmpty():
    name, time = queue.dequeue()
    if int(time) <= q:
        sum_time += int(time)
        print(name + ' ' + str(sum_time))
    else:
        queue.enqueue([name, str(int(time) - q)])
        sum_time += q

