class Process:
    def __init__(self, name_time):
        self.name = name_time[0]
        self.time = int(name_time[1])


process_amount, quontam = (int(i) for i in input().split(' '))

processes = [Process(input().split(' ')) for i in range(process_amount)]

i = 0
total_time = 0
while len(processes) != 0:
    process = processes[0]
    if process.time <= quontam:
        total_time += process.time
        print('{} {}'.format(process.name, total_time))
    else:
        total_time += quontam
        process.time -= quontam
        processes.append(process)

    processes.pop(0)
 class Process:
    def __init__(self, name_time):
        self.name = name_time[0]
        self.time = int(name_time[1]) Process def __init__(self, name_time):
        self.name = name_time[0]
        self.time = int(name_time[1]) __init__ self.name = name_time[0] self.name self name name_time[0] name_time 0 self.time = int(name_time[1]) self.time self time int(name_time[1]) int name_time[1] name_time 1 self self name_time name_time 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 process_amount, quontam = (int(i) for i in input().split(' ')) process_amount (int(i) for i in input().split(' ')) quontam Process(input().split(' ')) for i in range(process_amount) for i in range(process_amount) i range(process_amount) range process_amount for i in range(process_amount) Process(input().split(' ')) Process input().split(' ') ().split () input split ' ' processes = [Process(input().split(' ')) for i in range(process_amount)] processes [Process(input().split(' ')) for i in range(process_amount)] i = 0 i 0 total_time = 0 total_time 0 while len(processes) != 0:
    process = processes[0]
    if process.time <= quontam:
        total_time += process.time
        print('{} {}'.format(process.name, total_time))
    else:
        total_time += quontam
        process.time -= quontam
        processes.append(process)

    processes.pop(0) len(processes) != 0 len(processes) len processes 0 process = processes[0] process processes[0] processes 0 if process.time <= quontam:
        total_time += process.time
        print('{} {}'.format(process.name, total_time))
    else:
        total_time += quontam
        process.time -= quontam
        processes.append(process)

     process.time <= quontam process.time process time quontam total_time += process.time total_time process.time process time print('{} {}'.format(process.name, total_time)) print '{} {}'.format(process.name, total_time) '{} {}'.format '{} {}' format process.name process name total_time total_time += quontam total_time quontam process.time -= quontam process.time process time quontam processes.append(process) processes.append processes append process processes.pop(0) processes.pop processes pop 0 total_time = 0 0 total_time processes = [Process(input().split(' ')) for i in range(process_amount)] [Process(input().split(' ')) for i in range(process_amount)] processes i = 0 0 i total_time += quontam quontam total_time process_amount, quontam = (int(i) for i in input().split(' ')) (int(i) for i in input().split(' ')) process_amount process = processes[0] processes[0] process total_time += process.time process.time total_time class Process:
    def __init__(self, name_time):
        self.name = name_time[0]
        self.time = int(name_time[1]) class Process:
    def __init__(self, name_time):
        self.name = name_time[0]
        self.time = int(name_time[1]) Process quontam = (int(i) for i in input().split(' ')) (int(i) for i in input().split(' ')) quontam
class Process:
    def __init__(self, name_time):
        self.name = name_time[0]
        self.time = int(name_time[1])


process_amount, quontam = (int(i) for i in input().split(' '))

processes = [Process(input().split(' ')) for i in range(process_amount)]

i = 0
total_time = 0
while len(processes) != 0:
    process = processes[0]
    if process.time <= quontam:
        total_time += process.time
        print('{} {}'.format(process.name, total_time))
    else:
        total_time += quontam
        process.time -= quontam
        processes.append(process)

    processes.pop(0)

