n, q = map(int, input().split())
queue = list()
for i in range(n):
    p = input().split()
    queue.append({"name": p[0], "time": int(p[1])})

t = 0
while len(queue) > 0:
    proc = queue.pop(0)
    if q < proc["time"]:
        proc["time"] -= q
        t += q
        queue.append(proc)
    else:
        t += proc["time"]
        print(proc["name"], t) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q queue = list() queue list() list for i in range(n):
    p = input().split()
    queue.append({"name": p[0], "time": int(p[1])}) i range(n) range n p = input().split() p input().split() ().split () input split queue.append({"name": p[0], "time": int(p[1])}) queue.append queue append {"name": p[0], "time": int(p[1])} "name" "name" p[0] p 0 "time" "time" int(p[1]) int p[1] p 1 t = 0 t 0 while len(queue) > 0:
    proc = queue.pop(0)
    if q < proc["time"]:
        proc["time"] -= q
        t += q
        queue.append(proc)
    else:
        t += proc["time"]
        print(proc["name"], t) len(queue) > 0 len(queue) len queue 0 proc = queue.pop(0) proc queue.pop(0) queue.pop queue pop 0 if q < proc["time"]:
        proc["time"] -= q
        t += q
        queue.append(proc)
    else:
        t += proc["time"]
        print(proc["name"], t) q < proc["time"] q proc["time"] proc "time" proc["time"] -= q proc["time"] proc "time" q t += q t q queue.append(proc) queue.append queue append proc t += proc["time"] t proc["time"] proc "time" print(proc["name"], t) print proc["name"] proc "name" t queue = list() list() queue q = map(int, input().split()) map(int, input().split()) q p = input().split() input().split() p proc = queue.pop(0) queue.pop(0) proc n, q = map(int, input().split()) map(int, input().split()) n t = 0 0 t t += q q t t += proc["time"] proc["time"] t
n, q = map(int, input().split())
queue = list()
for i in range(n):
    p = input().split()
    queue.append({"name": p[0], "time": int(p[1])})

t = 0
while len(queue) > 0:
    proc = queue.pop(0)
    if q < proc["time"]:
        proc["time"] -= q
        t += q
        queue.append(proc)
    else:
        t += proc["time"]
        print(proc["name"], t)