# encoding: utf-8

n, q = map(int, raw_input().split())
queue = []
for i in xrange(n):
    name, time = raw_input().split()
    queue.append((name, int(time)))

time = 0
while queue:
    name, t = queue.pop(0)
    if q < t:
        time += q
        queue.append((name, t - q))
    else:
        time += t
        print name, time n, q = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split q queue = [] queue [] for i in xrange(n):
    name, time = raw_input().split()
    queue.append((name, int(time))) i xrange(n) xrange n name, time = raw_input().split() name raw_input().split() ().split () raw_input split time queue.append((name, int(time))) queue.append queue append (name, int(time)) name int(time) int time time = 0 time 0 while queue:
    name, t = queue.pop(0)
    if q < t:
        time += q
        queue.append((name, t - q))
    else:
        time += t
        print name, time queue name, t = queue.pop(0) name queue.pop(0) queue.pop queue pop 0 t if q < t:
        time += q
        queue.append((name, t - q))
    else:
        time += t
        print name, time q < t q t time += q time q queue.append((name, t - q)) queue.append queue append (name, t - q) name t - q t q time += t time t print name time queue = [] [] queue time += t t time q = map(int, raw_input().split()) map(int, raw_input().split()) q t = queue.pop(0) queue.pop(0) t time += q q time time = raw_input().split() raw_input().split() time name, time = raw_input().split() raw_input().split() name time = 0 0 time name, t = queue.pop(0) queue.pop(0) name n, q = map(int, raw_input().split()) map(int, raw_input().split()) n
# encoding: utf-8

n, q = map(int, raw_input().split())
queue = []
for i in xrange(n):
    name, time = raw_input().split()
    queue.append((name, int(time)))

time = 0
while queue:
    name, t = queue.pop(0)
    if q < t:
        time += q
        queue.append((name, t - q))
    else:
        time += t
        print name, time