#
# coding: utf-8

n, quantum = map(int, raw_input().split())

process_time = []
tim = 0

for x in xrange(n):
    pros, tt = raw_input().split()
    process_time.append([pros, int(tt)])

while True:
    if len(process_time) == 0: break
    pp = process_time.pop(0)
    if pp[1] > quantum :
        pp[1] = pp[1] - quantum
        process_time.append(pp)
        tim += quantum
    else:
        tim += pp[1]
        print pp[0] + " " +str(tim) n, quantum = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split quantum process_time = [] process_time [] tim = 0 tim 0 for x in xrange(n):
    pros, tt = raw_input().split()
    process_time.append([pros, int(tt)]) x xrange(n) xrange n pros, tt = raw_input().split() pros raw_input().split() ().split () raw_input split tt process_time.append([pros, int(tt)]) process_time.append process_time append [pros, int(tt)] pros int(tt) int tt while True:
    if len(process_time) == 0: break
    pp = process_time.pop(0)
    if pp[1] > quantum :
        pp[1] = pp[1] - quantum
        process_time.append(pp)
        tim += quantum
    else:
        tim += pp[1]
        print pp[0] + " " +str(tim) True if len(process_time) == 0: break
     len(process_time) == 0 len(process_time) len process_time 0 pp = process_time.pop(0) pp process_time.pop(0) process_time.pop process_time pop 0 if pp[1] > quantum :
        pp[1] = pp[1] - quantum
        process_time.append(pp)
        tim += quantum
    else:
        tim += pp[1]
        print pp[0] + " " +str(tim) pp[1] > quantum pp[1] pp 1 quantum pp[1] = pp[1] - quantum pp[1] pp 1 pp[1] - quantum pp[1] pp 1 quantum process_time.append(pp) process_time.append process_time append pp tim += quantum tim quantum tim += pp[1] tim pp[1] pp 1 print pp[0] + " " +str(tim) pp[0] + " " pp[0] pp 0 " " str(tim) str tim pros, tt = raw_input().split() raw_input().split() pros n, quantum = map(int, raw_input().split()) map(int, raw_input().split()) n tim = 0 0 tim tim += pp[1] pp[1] tim quantum = map(int, raw_input().split()) map(int, raw_input().split()) quantum process_time = [] [] process_time tt = raw_input().split() raw_input().split() tt pp = process_time.pop(0) process_time.pop(0) pp tim += quantum quantum tim
#
# coding: utf-8

n, quantum = map(int, raw_input().split())

process_time = []
tim = 0

for x in xrange(n):
    pros, tt = raw_input().split()
    process_time.append([pros, int(tt)])

while True:
    if len(process_time) == 0: break
    pp = process_time.pop(0)
    if pp[1] > quantum :
        pp[1] = pp[1] - quantum
        process_time.append(pp)
        tim += quantum
    else:
        tim += pp[1]
        print pp[0] + " " +str(tim)