# input
n, q = map(int, raw_input().split())
procs = [raw_input().split() for i in xrange(n)]
procs = list(reversed(procs))

# procsessing
cnt, lack = 0, 1
while lack > 0:
    lack = 0
    tprocs = []
    for i in xrange(n):
        proc = procs.pop()
        t = int(proc[1])
        if t <= q:
            cnt += t
            print proc[0], cnt
            n -= 1
        else: # t > q
            cnt += q
            t = t - q
            lack += t
            proc[1] = str(t)
            tprocs.append(proc)
    procs = list(reversed(tprocs)) 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 xrange(n) for i in xrange(n) i xrange(n) xrange n for i in xrange(n) raw_input().split() ().split () raw_input split procs = [raw_input().split() for i in xrange(n)] procs [raw_input().split() for i in xrange(n)] procs = list(reversed(procs)) procs list(reversed(procs)) list reversed(procs) reversed procs cnt, lack = 0, 1 cnt 0 lack 1 while lack > 0:
    lack = 0
    tprocs = []
    for i in xrange(n):
        proc = procs.pop()
        t = int(proc[1])
        if t <= q:
            cnt += t
            print proc[0], cnt
            n -= 1
        else: # t > q
            cnt += q
            t = t - q
            lack += t
            proc[1] = str(t)
            tprocs.append(proc)
    procs = list(reversed(tprocs)) lack > 0 lack 0 lack = 0 lack 0 tprocs = [] tprocs [] for i in xrange(n):
        proc = procs.pop()
        t = int(proc[1])
        if t <= q:
            cnt += t
            print proc[0], cnt
            n -= 1
        else: # t > q
            cnt += q
            t = t - q
            lack += t
            proc[1] = str(t)
            tprocs.append(proc)
     i xrange(n) xrange n proc = procs.pop() proc procs.pop() procs.pop procs pop t = int(proc[1]) t int(proc[1]) int proc[1] proc 1 if t <= q:
            cnt += t
            print proc[0], cnt
            n -= 1
        else: # t > q
            cnt += q
            t = t - q
            lack += t
            proc[1] = str(t)
            tprocs.append(proc)
     t <= q t q cnt += t cnt t print proc[0] proc 0 cnt n -= 1 n 1 cnt += q cnt q t = t - q t t - q t q lack += t lack t proc[1] = str(t) proc[1] proc 1 str(t) str t tprocs.append(proc) tprocs.append tprocs append proc procs = list(reversed(tprocs)) procs list(reversed(tprocs)) list reversed(tprocs) reversed tprocs proc = procs.pop() procs.pop() proc lack = 0 0 lack n, q = map(int, raw_input().split()) map(int, raw_input().split()) n lack = 0, 1 1 lack q = map(int, raw_input().split()) map(int, raw_input().split()) q procs = list(reversed(procs)) list(reversed(procs)) procs procs = [raw_input().split() for i in xrange(n)] [raw_input().split() for i in xrange(n)] procs cnt += t t cnt n -= 1 1 n cnt, lack = 0, 1 0 cnt tprocs = [] [] tprocs procs = list(reversed(tprocs)) list(reversed(tprocs)) procs t = int(proc[1]) int(proc[1]) t t = t - q t - q t lack += t t lack cnt += q q cnt
# input
n, q = map(int, raw_input().split())
procs = [raw_input().split() for i in xrange(n)]
procs = list(reversed(procs))

# procsessing
cnt, lack = 0, 1
while lack > 0:
    lack = 0
    tprocs = []
    for i in xrange(n):
        proc = procs.pop()
        t = int(proc[1])
        if t <= q:
            cnt += t
            print proc[0], cnt
            n -= 1
        else: # t > q
            cnt += q
            t = t - q
            lack += t
            proc[1] = str(t)
            tprocs.append(proc)
    procs = list(reversed(tprocs))