process_num, qms = map(int, input().split())
raw_procs = [input() for i in range(process_num)]


if __name__ == '__main__':
    procs = []
    for row in raw_procs:
        name, time = row.split()
        procs.append({
            "name": name,
            "time": int(time),
        })

    total_time = 0
    current_proc = 0
    while len(procs) > 0:
        if procs[current_proc]["time"] > qms:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc == len(procs):
                current_proc = 0 process_num, qms = map(int, input().split()) process_num map(int, input().split()) map int input().split() ().split () input split qms input() for i in range(process_num) for i in range(process_num) i range(process_num) range process_num for i in range(process_num) input() input raw_procs = [input() for i in range(process_num)] raw_procs [input() for i in range(process_num)] if __name__ == '__main__':
    procs = []
    for row in raw_procs:
        name, time = row.split()
        procs.append({
            "name": name,
            "time": int(time),
        })

    total_time = 0
    current_proc = 0
    while len(procs) > 0:
        if procs[current_proc]["time"] > qms:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc == len(procs):
                current_proc = 0 __name__ == '__main__' __name__ '__main__' procs = [] procs [] for row in raw_procs:
        name, time = row.split()
        procs.append({
            "name": name,
            "time": int(time),
        })

     row raw_procs name, time = row.split() name row.split() row.split row split time procs.append({
            "name": name,
            "time": int(time),
        }) procs.append procs append {
            "name": name,
            "time": int(time),
        } "name" "name" name "time" "time" int(time) int time total_time = 0 total_time 0 current_proc = 0 current_proc 0 while len(procs) > 0:
        if procs[current_proc]["time"] > qms:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc == len(procs):
                current_proc = 0 len(procs) > 0 len(procs) len procs 0 if procs[current_proc]["time"] > qms:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc == len(procs):
                current_proc = 0 procs[current_proc]["time"] > qms procs[current_proc]["time"] [current_proc] procs current_proc "time" qms procs[current_proc]["time"] = procs[current_proc]["time"] - qms procs[current_proc]["time"] [current_proc] procs current_proc "time" procs[current_proc]["time"] - qms procs[current_proc]["time"] [current_proc] procs current_proc "time" qms total_time += qms total_time qms if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
         current_proc == len(procs)-1 current_proc len(procs)-1 len(procs) len procs 1 current_proc = 0 current_proc 0 current_proc += 1 current_proc 1 total_time += procs[current_proc]["time"] total_time procs[current_proc]["time"] [current_proc] procs current_proc "time" print("{} {}".format(procs[current_proc]["name"], total_time)) print "{} {}".format(procs[current_proc]["name"], total_time) "{} {}".format "{} {}" format procs[current_proc]["name"] [current_proc] procs current_proc "name" total_time del procs[current_proc] procs[current_proc] procs current_proc if current_proc == len(procs):
                current_proc = 0 current_proc == len(procs) current_proc len(procs) len procs current_proc = 0 current_proc 0 current_proc = 0 0 current_proc raw_procs = [input() for i in range(process_num)] [input() for i in range(process_num)] raw_procs procs = [] [] procs name, time = row.split() row.split() name total_time += procs[current_proc]["time"] procs[current_proc]["time"] total_time current_proc = 0 0 current_proc qms = map(int, input().split()) map(int, input().split()) qms total_time = 0 0 total_time total_time += qms qms total_time time = row.split() row.split() time current_proc = 0 0 current_proc current_proc += 1 1 current_proc process_num, qms = map(int, input().split()) map(int, input().split()) process_num
process_num, qms = map(int, input().split())
raw_procs = [input() for i in range(process_num)]


if __name__ == '__main__':
    procs = []
    for row in raw_procs:
        name, time = row.split()
        procs.append({
            "name": name,
            "time": int(time),
        })

    total_time = 0
    current_proc = 0
    while len(procs) > 0:
        if procs[current_proc]["time"] > qms:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc == len(procs):
                current_proc = 0
