def enqueue(x, queue):
    queue.append(x)
    return queue
def dequeue(queue):
    val = queue.pop(0)
    return val, queue

def isEmpty(queue):
    return queue!=[]
        
def work(q, process):
    process[1] = process[1] - q
    return process
    
n, q = map(int, input().split())
process = [input().split() for _ in range(n)]
process = [[one[0], int(one[1])] for one in process]
queue = process.copy()

time = 0
while isEmpty(queue):
    process, queue = dequeue(queue)
    process = work(q, process)
    if process[1]<=0:
        worktime = q+process[1]
        print(process[0]+ ' ' +str(time+worktime))
        time += worktime
    else:
        queue = enqueue(process, queue)
        time += q def enqueue(x, queue):
    queue.append(x)
    return queue enqueue queue.append(x) queue.append queue append x return queue queue x x queue queue def dequeue(queue):
    val = queue.pop(0)
    return val, queue dequeue val = queue.pop(0) val queue.pop(0) queue.pop queue pop 0 return val, queue return val, queue val queue queue queue def isEmpty(queue):
    return queue!=[]
         isEmpty return queue!=[] queue!=[] queue [] queue queue def work(q, process):
    process[1] = process[1] - q
    return process
     work process[1] = process[1] - q process[1] process 1 process[1] - q process[1] process 1 q return process process q q process process n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q input().split() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) input().split() ().split () input split process = [input().split() for _ in range(n)] process [input().split() for _ in range(n)] [one[0], int(one[1])] for one in process for one in process one process for one in process [one[0], int(one[1])] one[0] one 0 int(one[1]) int one[1] one 1 process = [[one[0], int(one[1])] for one in process] process [[one[0], int(one[1])] for one in process] queue = process.copy() queue process.copy() process.copy process copy time = 0 time 0 while isEmpty(queue):
    process, queue = dequeue(queue)
    process = work(q, process)
    if process[1]<=0:
        worktime = q+process[1]
        print(process[0]+ ' ' +str(time+worktime))
        time += worktime
    else:
        queue = enqueue(process, queue)
        time += q isEmpty(queue) isEmpty queue process, queue = dequeue(queue) process dequeue(queue) dequeue queue queue process = work(q, process) process work(q, process) work q process if process[1]<=0:
        worktime = q+process[1]
        print(process[0]+ ' ' +str(time+worktime))
        time += worktime
    else:
        queue = enqueue(process, queue)
        time += q process[1]<=0 process[1] process 1 0 worktime = q+process[1] worktime q+process[1] q process[1] process 1 print(process[0]+ ' ' +str(time+worktime)) print process[0]+ ' ' +str(time+worktime) process[0]+ ' ' process[0] process 0 ' ' str(time+worktime) str time+worktime time worktime time += worktime time worktime queue = enqueue(process, queue) queue enqueue(process, queue) enqueue process queue time += q time q time += worktime worktime time n, q = map(int, input().split()) map(int, input().split()) n process = [[one[0], int(one[1])] for one in process] [[one[0], int(one[1])] for one in process] process process = work(q, process) work(q, process) process process, queue = dequeue(queue) dequeue(queue) process time += q q time process = [input().split() for _ in range(n)] [input().split() for _ in range(n)] process worktime = q+process[1] q+process[1] worktime queue = enqueue(process, queue) enqueue(process, queue) queue queue = dequeue(queue) dequeue(queue) queue def dequeue(queue):
    val = queue.pop(0)
    return val, queue def dequeue(queue):
    val = queue.pop(0)
    return val, queue dequeue def enqueue(x, queue):
    queue.append(x)
    return queue def enqueue(x, queue):
    queue.append(x)
    return queue enqueue def isEmpty(queue):
    return queue!=[]
         def isEmpty(queue):
    return queue!=[]
         isEmpty time = 0 0 time def work(q, process):
    process[1] = process[1] - q
    return process
     def work(q, process):
    process[1] = process[1] - q
    return process
     work queue = process.copy() process.copy() queue q = map(int, input().split()) map(int, input().split()) q
def enqueue(x, queue):
    queue.append(x)
    return queue
def dequeue(queue):
    val = queue.pop(0)
    return val, queue

def isEmpty(queue):
    return queue!=[]
        
def work(q, process):
    process[1] = process[1] - q
    return process
    
n, q = map(int, input().split())
process = [input().split() for _ in range(n)]
process = [[one[0], int(one[1])] for one in process]
queue = process.copy()

time = 0
while isEmpty(queue):
    process, queue = dequeue(queue)
    process = work(q, process)
    if process[1]<=0:
        worktime = q+process[1]
        print(process[0]+ ' ' +str(time+worktime))
        time += worktime
    else:
        queue = enqueue(process, queue)
        time += q
