#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

n, quantum = map(int, sys.stdin.readline().split())

proc_q = list()
for i in range(n):
    p_name, length = sys.stdin.readline().split()
    proc_q.append([p_name, int(length)])

elapse = 0
while proc_q:
    process = proc_q.pop(0)  # retrieve 1st element
    p_time = min(quantum, process[1])
    elapse += p_time
    if p_time == process[1]:
        print(process[0], elapse)
    else:
        proc_q.append([process[0], process[1]-quantum])
 import sys sys n, quantum = 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 quantum proc_q = list() proc_q list() list for i in range(n):
    p_name, length = sys.stdin.readline().split()
    proc_q.append([p_name, int(length)]) i range(n) range n p_name, length = sys.stdin.readline().split() p_name sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split length proc_q.append([p_name, int(length)]) proc_q.append proc_q append [p_name, int(length)] p_name int(length) int length elapse = 0 elapse 0 while proc_q:
    process = proc_q.pop(0)  # retrieve 1st element
    p_time = min(quantum, process[1])
    elapse += p_time
    if p_time == process[1]:
        print(process[0], elapse)
    else:
        proc_q.append([process[0], process[1]-quantum]) proc_q process = proc_q.pop(0) process proc_q.pop(0) proc_q.pop proc_q pop 0 p_time = min(quantum, process[1]) p_time min(quantum, process[1]) min quantum process[1] process 1 elapse += p_time elapse p_time if p_time == process[1]:
        print(process[0], elapse)
    else:
        proc_q.append([process[0], process[1]-quantum]) p_time == process[1] p_time process[1] process 1 print(process[0], elapse) print process[0] process 0 elapse proc_q.append([process[0], process[1]-quantum]) proc_q.append proc_q append [process[0], process[1]-quantum] process[0] process 0 process[1]-quantum process[1] process 1 quantum p_name, length = sys.stdin.readline().split() sys.stdin.readline().split() p_name length = sys.stdin.readline().split() sys.stdin.readline().split() length quantum = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) quantum elapse = 0 0 elapse elapse += p_time p_time elapse n, quantum = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n proc_q = list() list() proc_q process = proc_q.pop(0) proc_q.pop(0) process p_time = min(quantum, process[1]) min(quantum, process[1]) p_time
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

n, quantum = map(int, sys.stdin.readline().split())

proc_q = list()
for i in range(n):
    p_name, length = sys.stdin.readline().split()
    proc_q.append([p_name, int(length)])

elapse = 0
while proc_q:
    process = proc_q.pop(0)  # retrieve 1st element
    p_time = min(quantum, process[1])
    elapse += p_time
    if p_time == process[1]:
        print(process[0], elapse)
    else:
        proc_q.append([process[0], process[1]-quantum])

