n, q = [int(i) for i in input().split()]
process = []
for i in range(n):
    name, time = input().split()
    process.append([name, int(time)])

count = 0
while True:
    if len(process) == 0: break
    if process[0][1] <= q:
        count += process[0][1]
        print(process[0][0], count)
        process[0][1] = process[0][1] - q
        process.pop(0)
    else:
        count += q
        process[0][1] = process[0][1] - q
        process.append(process.pop(0)) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n, q = [int(i) for i in input().split()] n [int(i) for i in input().split()] q process = [] process [] for i in range(n):
    name, time = input().split()
    process.append([name, int(time)]) i range(n) range n name, time = input().split() name input().split() ().split () input split time process.append([name, int(time)]) process.append process append [name, int(time)] name int(time) int time count = 0 count 0 while True:
    if len(process) == 0: break
    if process[0][1] <= q:
        count += process[0][1]
        print(process[0][0], count)
        process[0][1] = process[0][1] - q
        process.pop(0)
    else:
        count += q
        process[0][1] = process[0][1] - q
        process.append(process.pop(0)) True if len(process) == 0: break
     len(process) == 0 len(process) len process 0 if process[0][1] <= q:
        count += process[0][1]
        print(process[0][0], count)
        process[0][1] = process[0][1] - q
        process.pop(0)
    else:
        count += q
        process[0][1] = process[0][1] - q
        process.append(process.pop(0)) process[0][1] <= q process[0][1] [0] process 0 1 q count += process[0][1] count process[0][1] [0] process 0 1 print(process[0][0], count) print process[0][0] [0] process 0 0 count process[0][1] = process[0][1] - q process[0][1] [0] process 0 1 process[0][1] - q process[0][1] [0] process 0 1 q process.pop(0) process.pop process pop 0 count += q count q process[0][1] = process[0][1] - q process[0][1] [0] process 0 1 process[0][1] - q process[0][1] [0] process 0 1 q process.append(process.pop(0)) process.append process append process.pop(0) process.pop process pop 0 process = [] [] process time = input().split() input().split() time q = [int(i) for i in input().split()] [int(i) for i in input().split()] q count = 0 0 count count += process[0][1] process[0][1] count count += q q count n, q = [int(i) for i in input().split()] [int(i) for i in input().split()] n name, time = input().split() input().split() name
n, q = [int(i) for i in input().split()]
process = []
for i in range(n):
    name, time = input().split()
    process.append([name, int(time)])

count = 0
while True:
    if len(process) == 0: break
    if process[0][1] <= q:
        count += process[0][1]
        print(process[0][0], count)
        process[0][1] = process[0][1] - q
        process.pop(0)
    else:
        count += q
        process[0][1] = process[0][1] - q
        process.append(process.pop(0))