n, q = map(int, input().split())
input_list = []
for i in range(n):
    name, time = input().split()
    input_list.append([str(name), int(time)])
queue_head = 0
now_time = 0
while queue_head != len(input_list):
    if q < input_list[queue_head][1]:
        input_list.append([input_list[queue_head][0], input_list[queue_head][1] - q])
        queue_head += 1
        now_time += q
    else:
        now_time += input_list[queue_head][1]
        print(input_list[queue_head][0], now_time)
        queue_head += 1
 n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q input_list = [] input_list [] for i in range(n):
    name, time = input().split()
    input_list.append([str(name), int(time)]) i range(n) range n name, time = input().split() name input().split() ().split () input split time input_list.append([str(name), int(time)]) input_list.append input_list append [str(name), int(time)] str(name) str name int(time) int time queue_head = 0 queue_head 0 now_time = 0 now_time 0 while queue_head != len(input_list):
    if q < input_list[queue_head][1]:
        input_list.append([input_list[queue_head][0], input_list[queue_head][1] - q])
        queue_head += 1
        now_time += q
    else:
        now_time += input_list[queue_head][1]
        print(input_list[queue_head][0], now_time)
        queue_head += 1 queue_head != len(input_list) queue_head len(input_list) len input_list if q < input_list[queue_head][1]:
        input_list.append([input_list[queue_head][0], input_list[queue_head][1] - q])
        queue_head += 1
        now_time += q
    else:
        now_time += input_list[queue_head][1]
        print(input_list[queue_head][0], now_time)
        queue_head += 1 q < input_list[queue_head][1] q input_list[queue_head][1] [queue_head] input_list queue_head 1 input_list.append([input_list[queue_head][0], input_list[queue_head][1] - q]) input_list.append input_list append [input_list[queue_head][0], input_list[queue_head][1] - q] input_list[queue_head][0] [queue_head] input_list queue_head 0 input_list[queue_head][1] - q input_list[queue_head][1] [queue_head] input_list queue_head 1 q queue_head += 1 queue_head 1 now_time += q now_time q now_time += input_list[queue_head][1] now_time input_list[queue_head][1] [queue_head] input_list queue_head 1 print(input_list[queue_head][0], now_time) print input_list[queue_head][0] [queue_head] input_list queue_head 0 now_time queue_head += 1 queue_head 1 time = input().split() input().split() time queue_head = 0 0 queue_head queue_head += 1 1 queue_head now_time += input_list[queue_head][1] input_list[queue_head][1] now_time now_time += q q now_time queue_head += 1 1 queue_head q = map(int, input().split()) map(int, input().split()) q n, q = map(int, input().split()) map(int, input().split()) n name, time = input().split() input().split() name now_time = 0 0 now_time input_list = [] [] input_list
n, q = map(int, input().split())
input_list = []
for i in range(n):
    name, time = input().split()
    input_list.append([str(name), int(time)])
queue_head = 0
now_time = 0
while queue_head != len(input_list):
    if q < input_list[queue_head][1]:
        input_list.append([input_list[queue_head][0], input_list[queue_head][1] - q])
        queue_head += 1
        now_time += q
    else:
        now_time += input_list[queue_head][1]
        print(input_list[queue_head][0], now_time)
        queue_head += 1

