import queue


nq = input().split()
n = int(nq[0])
q = int(nq[1])

qu = queue.Queue()
for _ in range(n):
    nt = input().split()
    qu.put({"name": nt[0], "time": int(nt[1])})

t = 0
while not(qu.empty()):
    process = qu.get()
    if process["time"] > q:
        process["time"] -= q
        t += q
        qu.put(process)
    else:
        t += process["time"]
        print(process["name"], t) import queue queue nq = input().split() nq input().split() ().split () input split n = int(nq[0]) n int(nq[0]) int nq[0] nq 0 q = int(nq[1]) q int(nq[1]) int nq[1] nq 1 qu = queue.Queue() qu queue.Queue() queue.Queue queue Queue for _ in range(n):
    nt = input().split()
    qu.put({"name": nt[0], "time": int(nt[1])}) _ range(n) range n nt = input().split() nt input().split() ().split () input split qu.put({"name": nt[0], "time": int(nt[1])}) qu.put qu put {"name": nt[0], "time": int(nt[1])} "name" "name" nt[0] nt 0 "time" "time" int(nt[1]) int nt[1] nt 1 t = 0 t 0 while not(qu.empty()):
    process = qu.get()
    if process["time"] > q:
        process["time"] -= q
        t += q
        qu.put(process)
    else:
        t += process["time"]
        print(process["name"], t) not(qu.empty()) qu.empty() qu.empty qu empty process = qu.get() process qu.get() qu.get qu get if process["time"] > q:
        process["time"] -= q
        t += q
        qu.put(process)
    else:
        t += process["time"]
        print(process["name"], t) process["time"] > q process["time"] process "time" q process["time"] -= q process["time"] process "time" q t += q t q qu.put(process) qu.put qu put process t += process["time"] t process["time"] process "time" print(process["name"], t) print process["name"] process "name" t nq = input().split() input().split() nq t = 0 0 t t += q q t q = int(nq[1]) int(nq[1]) q nt = input().split() input().split() nt qu = queue.Queue() queue.Queue() qu n = int(nq[0]) int(nq[0]) n process = qu.get() qu.get() process t += process["time"] process["time"] t
import queue


nq = input().split()
n = int(nq[0])
q = int(nq[1])

qu = queue.Queue()
for _ in range(n):
    nt = input().split()
    qu.put({"name": nt[0], "time": int(nt[1])})

t = 0
while not(qu.empty()):
    process = qu.get()
    if process["time"] > q:
        process["time"] -= q
        t += q
        qu.put(process)
    else:
        t += process["time"]
        print(process["name"], t)
