n, quantum = list(map(int, input().split()))
queue = []
sumOfTime = 0

for _ in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while len(queue) > 0:
    name, time = queue.pop(0)
    if time > quantum:
        sumOfTime += quantum
        queue.append([name, time - quantum])
    else:
        sumOfTime += time
        print(name, sumOfTime)
 n, quantum = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split quantum queue = [] queue [] sumOfTime = 0 sumOfTime 0 for _ in range(n):
    name, time = input().split()
    queue.append([name, int(time)]) _ range(n) range n name, time = input().split() name input().split() ().split () input split time queue.append([name, int(time)]) queue.append queue append [name, int(time)] name int(time) int time while len(queue) > 0:
    name, time = queue.pop(0)
    if time > quantum:
        sumOfTime += quantum
        queue.append([name, time - quantum])
    else:
        sumOfTime += time
        print(name, sumOfTime) len(queue) > 0 len(queue) len queue 0 name, time = queue.pop(0) name queue.pop(0) queue.pop queue pop 0 time if time > quantum:
        sumOfTime += quantum
        queue.append([name, time - quantum])
    else:
        sumOfTime += time
        print(name, sumOfTime) time > quantum time quantum sumOfTime += quantum sumOfTime quantum queue.append([name, time - quantum]) queue.append queue append [name, time - quantum] name time - quantum time quantum sumOfTime += time sumOfTime time print(name, sumOfTime) print name sumOfTime time = input().split() input().split() time sumOfTime += quantum quantum sumOfTime time = queue.pop(0) queue.pop(0) time quantum = list(map(int, input().split())) list(map(int, input().split())) quantum queue = [] [] queue name, time = input().split() input().split() name name, time = queue.pop(0) queue.pop(0) name sumOfTime += time time sumOfTime n, quantum = list(map(int, input().split())) list(map(int, input().split())) n sumOfTime = 0 0 sumOfTime
n, quantum = list(map(int, input().split()))
queue = []
sumOfTime = 0

for _ in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while len(queue) > 0:
    name, time = queue.pop(0)
    if time > quantum:
        sumOfTime += quantum
        queue.append([name, time - quantum])
    else:
        sumOfTime += time
        print(name, sumOfTime)

