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

import collections

n, q = map(int, raw_input().split())
prolist = [raw_input().split() for i in range(n)]
prolist = collections.deque(prolist)
time_sum = 0
while len(prolist):
    process = prolist.popleft()
    time = int(process[1])
    if time <= q:
        time_sum += time
        print "%s %d" %(process[0], time_sum)
    else:
        time_sum += q
        process[1] = str(time-q)
        prolist.append(process) import collections collections n, q = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split q raw_input().split() for i in range(n) for i in range(n) i range(n) range n for i in range(n) raw_input().split() ().split () raw_input split prolist = [raw_input().split() for i in range(n)] prolist [raw_input().split() for i in range(n)] prolist = collections.deque(prolist) prolist collections.deque(prolist) collections.deque collections deque prolist time_sum = 0 time_sum 0 while len(prolist):
    process = prolist.popleft()
    time = int(process[1])
    if time <= q:
        time_sum += time
        print "%s %d" %(process[0], time_sum)
    else:
        time_sum += q
        process[1] = str(time-q)
        prolist.append(process) len(prolist) len prolist process = prolist.popleft() process prolist.popleft() prolist.popleft prolist popleft time = int(process[1]) time int(process[1]) int process[1] process 1 if time <= q:
        time_sum += time
        print "%s %d" %(process[0], time_sum)
    else:
        time_sum += q
        process[1] = str(time-q)
        prolist.append(process) time <= q time q time_sum += time time_sum time print "%s %d" %(process[0], time_sum) "%s %d" (process[0], time_sum) process[0] process 0 time_sum time_sum += q time_sum q process[1] = str(time-q) process[1] process 1 str(time-q) str time-q time q prolist.append(process) prolist.append prolist append process prolist = collections.deque(prolist) collections.deque(prolist) prolist q = map(int, raw_input().split()) map(int, raw_input().split()) q process = prolist.popleft() prolist.popleft() process prolist = [raw_input().split() for i in range(n)] [raw_input().split() for i in range(n)] prolist time = int(process[1]) int(process[1]) time n, q = map(int, raw_input().split()) map(int, raw_input().split()) n time_sum += time time time_sum time_sum = 0 0 time_sum time_sum += q q time_sum
# -*- coding: utf-8 -*-

import collections

n, q = map(int, raw_input().split())
prolist = [raw_input().split() for i in range(n)]
prolist = collections.deque(prolist)
time_sum = 0
while len(prolist):
    process = prolist.popleft()
    time = int(process[1])
    if time <= q:
        time_sum += time
        print "%s %d" %(process[0], time_sum)
    else:
        time_sum += q
        process[1] = str(time-q)
        prolist.append(process)