n, q = map(int, raw_input().split(" "))
process = {}
schedule = []
sec = 0

for i in range(n):
    p, time = raw_input().split(" ")
    process[p] = int(time)
    schedule.append(p)

while len(schedule) != 0:
    p = schedule.pop(0)
    if process[p] - q > 0:
        process[p] -= q
        schedule.append(p)
        sec += q
    else:
        sec += process[p]
        print(p + " " + str(sec)) n, q = map(int, raw_input().split(" ")) n map(int, raw_input().split(" ")) map int raw_input().split(" ") ().split () raw_input split " " q process = {} process {} schedule = [] schedule [] sec = 0 sec 0 for i in range(n):
    p, time = raw_input().split(" ")
    process[p] = int(time)
    schedule.append(p) i range(n) range n p, time = raw_input().split(" ") p raw_input().split(" ") ().split () raw_input split " " time process[p] = int(time) process[p] process p int(time) int time schedule.append(p) schedule.append schedule append p while len(schedule) != 0:
    p = schedule.pop(0)
    if process[p] - q > 0:
        process[p] -= q
        schedule.append(p)
        sec += q
    else:
        sec += process[p]
        print(p + " " + str(sec)) len(schedule) != 0 len(schedule) len schedule 0 p = schedule.pop(0) p schedule.pop(0) schedule.pop schedule pop 0 if process[p] - q > 0:
        process[p] -= q
        schedule.append(p)
        sec += q
    else:
        sec += process[p]
        print(p + " " + str(sec)) process[p] - q > 0 process[p] - q process[p] process p q 0 process[p] -= q process[p] process p q schedule.append(p) schedule.append schedule append p sec += q sec q sec += process[p] sec process[p] process p print(p + " " + str(sec)) print p + " " + str(sec) p + " " p " " str(sec) str sec schedule = [] [] schedule sec = 0 0 sec n, q = map(int, raw_input().split(" ")) map(int, raw_input().split(" ")) n process = {} {} process time = raw_input().split(" ") raw_input().split(" ") time p = schedule.pop(0) schedule.pop(0) p sec += process[p] process[p] sec q = map(int, raw_input().split(" ")) map(int, raw_input().split(" ")) q p, time = raw_input().split(" ") raw_input().split(" ") p sec += q q sec
n, q = map(int, raw_input().split(" "))
process = {}
schedule = []
sec = 0

for i in range(n):
    p, time = raw_input().split(" ")
    process[p] = int(time)
    schedule.append(p)

while len(schedule) != 0:
    p = schedule.pop(0)
    if process[p] - q > 0:
        process[p] -= q
        schedule.append(p)
        sec += q
    else:
        sec += process[p]
        print(p + " " + str(sec))