#coding:utf-8
n, t_u = map(int,input().split())
name_pro_dict = {}
for i in range(n):
    name, pro = input().split()
    name_pro_dict[name] = int(pro)

t = 0
while name_pro_dict:
    keys = list(name_pro_dict.keys())
    for key in keys:
        if name_pro_dict[key] <= t_u:
            t += name_pro_dict[key]
            print(key, t)
            del name_pro_dict[key]
        else:
            name_pro_dict[key] -= t_u
            t += t_u
             n, t_u = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split t_u name_pro_dict = {} name_pro_dict {} for i in range(n):
    name, pro = input().split()
    name_pro_dict[name] = int(pro) i range(n) range n name, pro = input().split() name input().split() ().split () input split pro name_pro_dict[name] = int(pro) name_pro_dict[name] name_pro_dict name int(pro) int pro t = 0 t 0 while name_pro_dict:
    keys = list(name_pro_dict.keys())
    for key in keys:
        if name_pro_dict[key] <= t_u:
            t += name_pro_dict[key]
            print(key, t)
            del name_pro_dict[key]
        else:
            name_pro_dict[key] -= t_u
            t += t_u
             name_pro_dict keys = list(name_pro_dict.keys()) keys list(name_pro_dict.keys()) list name_pro_dict.keys() name_pro_dict.keys name_pro_dict keys for key in keys:
        if name_pro_dict[key] <= t_u:
            t += name_pro_dict[key]
            print(key, t)
            del name_pro_dict[key]
        else:
            name_pro_dict[key] -= t_u
            t += t_u
             key keys if name_pro_dict[key] <= t_u:
            t += name_pro_dict[key]
            print(key, t)
            del name_pro_dict[key]
        else:
            name_pro_dict[key] -= t_u
            t += t_u
             name_pro_dict[key] <= t_u name_pro_dict[key] name_pro_dict key t_u t += name_pro_dict[key] t name_pro_dict[key] name_pro_dict key print(key, t) print key t del name_pro_dict[key] name_pro_dict[key] name_pro_dict key name_pro_dict[key] -= t_u name_pro_dict[key] name_pro_dict key t_u t += t_u t t_u t = 0 0 t name, pro = input().split() input().split() name name_pro_dict = {} {} name_pro_dict pro = input().split() input().split() pro t_u = map(int,input().split()) map(int,input().split()) t_u t += name_pro_dict[key] name_pro_dict[key] t keys = list(name_pro_dict.keys()) list(name_pro_dict.keys()) keys n, t_u = map(int,input().split()) map(int,input().split()) n t += t_u t_u t
#coding:utf-8
n, t_u = map(int,input().split())
name_pro_dict = {}
for i in range(n):
    name, pro = input().split()
    name_pro_dict[name] = int(pro)

t = 0
while name_pro_dict:
    keys = list(name_pro_dict.keys())
    for key in keys:
        if name_pro_dict[key] <= t_u:
            t += name_pro_dict[key]
            print(key, t)
            del name_pro_dict[key]
        else:
            name_pro_dict[key] -= t_u
            t += t_u
            
