# -*- coding: utf-8 -*-

from collections import deque

queue = deque()
input_list = [int(i) for i in input().split()]
for i in range(input_list[0]):
    proc = input().split()
    queue.append([proc[0],int(proc[1])])

count = 0
while len(queue) != 0:
    proc = queue.popleft()
    if input_list[1] < proc[1]:
        queue.append([proc[0],proc[1]-input_list[1]])
        count += input_list[1]
    else:
        count += proc[1]
        print(proc[0] + ' ' + str(count)) from collections import deque queue = deque() queue deque() deque int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i input_list = [int(i) for i in input().split()] input_list [int(i) for i in input().split()] for i in range(input_list[0]):
    proc = input().split()
    queue.append([proc[0],int(proc[1])]) i range(input_list[0]) range input_list[0] input_list 0 proc = input().split() proc input().split() ().split () input split queue.append([proc[0],int(proc[1])]) queue.append queue append [proc[0],int(proc[1])] proc[0] proc 0 int(proc[1]) int proc[1] proc 1 count = 0 count 0 while len(queue) != 0:
    proc = queue.popleft()
    if input_list[1] < proc[1]:
        queue.append([proc[0],proc[1]-input_list[1]])
        count += input_list[1]
    else:
        count += proc[1]
        print(proc[0] + ' ' + str(count)) len(queue) != 0 len(queue) len queue 0 proc = queue.popleft() proc queue.popleft() queue.popleft queue popleft if input_list[1] < proc[1]:
        queue.append([proc[0],proc[1]-input_list[1]])
        count += input_list[1]
    else:
        count += proc[1]
        print(proc[0] + ' ' + str(count)) input_list[1] < proc[1] input_list[1] input_list 1 proc[1] proc 1 queue.append([proc[0],proc[1]-input_list[1]]) queue.append queue append [proc[0],proc[1]-input_list[1]] proc[0] proc 0 proc[1]-input_list[1] proc[1] proc 1 input_list[1] input_list 1 count += input_list[1] count input_list[1] input_list 1 count += proc[1] count proc[1] proc 1 print(proc[0] + ' ' + str(count)) print proc[0] + ' ' + str(count) proc[0] + ' ' proc[0] proc 0 ' ' str(count) str count proc = queue.popleft() queue.popleft() proc input_list = [int(i) for i in input().split()] [int(i) for i in input().split()] input_list count += input_list[1] input_list[1] count count = 0 0 count count += proc[1] proc[1] count queue = deque() deque() queue proc = input().split() input().split() proc
# -*- coding: utf-8 -*-

from collections import deque

queue = deque()
input_list = [int(i) for i in input().split()]
for i in range(input_list[0]):
    proc = input().split()
    queue.append([proc[0],int(proc[1])])

count = 0
while len(queue) != 0:
    proc = queue.popleft()
    if input_list[1] < proc[1]:
        queue.append([proc[0],proc[1]-input_list[1]])
        count += input_list[1]
    else:
        count += proc[1]
        print(proc[0] + ' ' + str(count))