import sys
n, q = map(int, sys.stdin.readline().split())
processes = []
for i in range(n):
    name, time =sys.stdin.readline().split()
    processes += [[name, int(time)]]

progress = 0

while len(processes):
    new_processes = []
    for target in processes:
        if target[1] > q:
            target[1] -= q
            progress += q
            new_processes += [target]
        else:
            progress += target[1]
            print(target[0], progress)
    processes = new_processes import sys sys n, q = map(int, sys.stdin.readline().split()) n map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split q processes = [] processes [] for i in range(n):
    name, time =sys.stdin.readline().split()
    processes += [[name, int(time)]] i range(n) range n name, time =sys.stdin.readline().split() name sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split time processes += [[name, int(time)]] processes [[name, int(time)]] [name, int(time)] name int(time) int time progress = 0 progress 0 while len(processes):
    new_processes = []
    for target in processes:
        if target[1] > q:
            target[1] -= q
            progress += q
            new_processes += [target]
        else:
            progress += target[1]
            print(target[0], progress)
    processes = new_processes len(processes) len processes new_processes = [] new_processes [] for target in processes:
        if target[1] > q:
            target[1] -= q
            progress += q
            new_processes += [target]
        else:
            progress += target[1]
            print(target[0], progress)
     target processes if target[1] > q:
            target[1] -= q
            progress += q
            new_processes += [target]
        else:
            progress += target[1]
            print(target[0], progress)
     target[1] > q target[1] target 1 q target[1] -= q target[1] target 1 q progress += q progress q new_processes += [target] new_processes [target] target progress += target[1] progress target[1] target 1 print(target[0], progress) print target[0] target 0 progress processes = new_processes processes new_processes q = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) q processes = new_processes new_processes processes new_processes = [] [] new_processes progress += target[1] target[1] progress n, q = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n processes += [[name, int(time)]] [[name, int(time)]] processes progress += q q progress processes = [] [] processes name, time =sys.stdin.readline().split() sys.stdin.readline().split() name time =sys.stdin.readline().split() sys.stdin.readline().split() time new_processes += [target] [target] new_processes progress = 0 0 progress
import sys
n, q = map(int, sys.stdin.readline().split())
processes = []
for i in range(n):
    name, time =sys.stdin.readline().split()
    processes += [[name, int(time)]]

progress = 0

while len(processes):
    new_processes = []
    for target in processes:
        if target[1] > q:
            target[1] -= q
            progress += q
            new_processes += [target]
        else:
            progress += target[1]
            print(target[0], progress)
    processes = new_processes