from collections import deque
n, q = map(int, input().split())
queue = deque()
for i in range(n):
    name, time = input().split()
    queue.append({"name": name, "time": int(time)})
t = 0
while len(queue) != 0:
    #print([queue[i]["time"] for i in range(len(queue))])
    head = queue.popleft()
    if head["time"] <= q:
        t += head["time"]
        name = head["name"]
        print("{} {}".format(name, t))
    else:
        queue.append({"name": head["name"], "time": head["time"] - q})
        t += q
 from collections import deque n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q queue = deque() queue deque() deque for i in range(n):
    name, time = input().split()
    queue.append({"name": name, "time": int(time)}) i range(n) range n name, time = input().split() name input().split() ().split () input split time queue.append({"name": name, "time": int(time)}) queue.append queue append {"name": name, "time": int(time)} "name" "name" name "time" "time" int(time) int time t = 0 t 0 while len(queue) != 0:
    #print([queue[i]["time"] for i in range(len(queue))])
    head = queue.popleft()
    if head["time"] <= q:
        t += head["time"]
        name = head["name"]
        print("{} {}".format(name, t))
    else:
        queue.append({"name": head["name"], "time": head["time"] - q})
        t += q len(queue) != 0 len(queue) len queue 0 head = queue.popleft() head queue.popleft() queue.popleft queue popleft if head["time"] <= q:
        t += head["time"]
        name = head["name"]
        print("{} {}".format(name, t))
    else:
        queue.append({"name": head["name"], "time": head["time"] - q})
        t += q head["time"] <= q head["time"] head "time" q t += head["time"] t head["time"] head "time" name = head["name"] name head["name"] head "name" print("{} {}".format(name, t)) print "{} {}".format(name, t) "{} {}".format "{} {}" format name t queue.append({"name": head["name"], "time": head["time"] - q}) queue.append queue append {"name": head["name"], "time": head["time"] - q} "name" "name" head["name"] head "name" "time" "time" head["time"] - q head["time"] head "time" q t += q t q time = input().split() input().split() time queue = deque() deque() queue n, q = map(int, input().split()) map(int, input().split()) n name, time = input().split() input().split() name head = queue.popleft() queue.popleft() head t = 0 0 t t += q q t q = map(int, input().split()) map(int, input().split()) q t += head["time"] head["time"] t name = head["name"] head["name"] name
from collections import deque
n, q = map(int, input().split())
queue = deque()
for i in range(n):
    name, time = input().split()
    queue.append({"name": name, "time": int(time)})
t = 0
while len(queue) != 0:
    #print([queue[i]["time"] for i in range(len(queue))])
    head = queue.popleft()
    if head["time"] <= q:
        t += head["time"]
        name = head["name"]
        print("{} {}".format(name, t))
    else:
        queue.append({"name": head["name"], "time": head["time"] - q})
        t += q

