n, q = map(int, input().split())

processes = []

for i in range(int(n)):
    process_name, process_time = input().split()
    processes.append([process_name, int(process_time)])

elapsed_time = 0
while len(processes):
    process = processes.pop(0)
    if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q processes = [] processes [] for i in range(int(n)):
    process_name, process_time = input().split()
    processes.append([process_name, int(process_time)]) i range(int(n)) range int(n) int n process_name, process_time = input().split() process_name input().split() ().split () input split process_time processes.append([process_name, int(process_time)]) processes.append processes append [process_name, int(process_time)] process_name int(process_time) int process_time elapsed_time = 0 elapsed_time 0 while len(processes):
    process = processes.pop(0)
    if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time) len(processes) len processes process = processes.pop(0) process processes.pop(0) processes.pop processes pop 0 if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time) process[1] > q process[1] process 1 q process[1] -= q process[1] process 1 q processes.append(process) processes.append processes append process elapsed_time += q elapsed_time q elapsed_time += process[1] elapsed_time process[1] process 1 print(process[0], elapsed_time) print process[0] process 0 elapsed_time elapsed_time += process[1] process[1] elapsed_time elapsed_time += q q elapsed_time q = map(int, input().split()) map(int, input().split()) q processes = [] [] processes process_time = input().split() input().split() process_time elapsed_time = 0 0 elapsed_time process_name, process_time = input().split() input().split() process_name n, q = map(int, input().split()) map(int, input().split()) n process = processes.pop(0) processes.pop(0) process
n, q = map(int, input().split())

processes = []

for i in range(int(n)):
    process_name, process_time = input().split()
    processes.append([process_name, int(process_time)])

elapsed_time = 0
while len(processes):
    process = processes.pop(0)
    if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time)