import queue
q = queue.Queue()
exetime = 0

n, quantum = map(int, input().split())
for i in range(n):
    q.put(tuple(input().split())) # tupleで渡す

while not q.empty():
    process = q.get()
    #print(process)
    time = int(process[1])
    if time > quantum:
        exetime += quantum
        q.put((process[0], time - quantum))
    else:
        exetime += time
        print(process[0], exetime) import queue queue q = queue.Queue() q queue.Queue() queue.Queue queue Queue exetime = 0 exetime 0 n, quantum = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split quantum for i in range(n):
    q.put(tuple(input().split())) # tupleで渡す i range(n) range n q.put(tuple(input().split())) q.put q put tuple(input().split()) tuple input().split() ().split () input split while not q.empty():
    process = q.get()
    #print(process)
    time = int(process[1])
    if time > quantum:
        exetime += quantum
        q.put((process[0], time - quantum))
    else:
        exetime += time
        print(process[0], exetime) not q.empty() q.empty() q.empty q empty process = q.get() process q.get() q.get q get time = int(process[1]) time int(process[1]) int process[1] process 1 if time > quantum:
        exetime += quantum
        q.put((process[0], time - quantum))
    else:
        exetime += time
        print(process[0], exetime) time > quantum time quantum exetime += quantum exetime quantum q.put((process[0], time - quantum)) q.put q put (process[0], time - quantum) process[0] process 0 time - quantum time quantum exetime += time exetime time print(process[0], exetime) print process[0] process 0 exetime exetime += quantum quantum exetime quantum = map(int, input().split()) map(int, input().split()) quantum exetime = 0 0 exetime exetime += time time exetime time = int(process[1]) int(process[1]) time q = queue.Queue() queue.Queue() q process = q.get() q.get() process n, quantum = map(int, input().split()) map(int, input().split()) n
import queue
q = queue.Queue()
exetime = 0

n, quantum = map(int, input().split())
for i in range(n):
    q.put(tuple(input().split())) # tupleで渡す

while not q.empty():
    process = q.get()
    #print(process)
    time = int(process[1])
    if time > quantum:
        exetime += quantum
        q.put((process[0], time - quantum))
    else:
        exetime += time
        print(process[0], exetime)
