n, q = map(int, input().split())
data = []
for i in range(n):
    tmp = input().split()
    tmp[1] = int(tmp[1])
    data.append(tmp)

dt_out = []
time_count = 0

while len(data) > 0 :
    tmp = data.pop(0)
    if(tmp[1] <= q):
        time_count += tmp[1]
        dt_out.append([tmp[0],time_count])
    else:
        tmp[1] -= q
        time_count += q
        data.append(tmp)

for tmp in dt_out:
    print(tmp[0]+" "+str(tmp[1])) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q data = [] data [] for i in range(n):
    tmp = input().split()
    tmp[1] = int(tmp[1])
    data.append(tmp) i range(n) range n tmp = input().split() tmp input().split() ().split () input split tmp[1] = int(tmp[1]) tmp[1] tmp 1 int(tmp[1]) int tmp[1] tmp 1 data.append(tmp) data.append data append tmp dt_out = [] dt_out [] time_count = 0 time_count 0 while len(data) > 0 :
    tmp = data.pop(0)
    if(tmp[1] <= q):
        time_count += tmp[1]
        dt_out.append([tmp[0],time_count])
    else:
        tmp[1] -= q
        time_count += q
        data.append(tmp) len(data) > 0 len(data) len data 0 tmp = data.pop(0) tmp data.pop(0) data.pop data pop 0 if(tmp[1] <= q):
        time_count += tmp[1]
        dt_out.append([tmp[0],time_count])
    else:
        tmp[1] -= q
        time_count += q
        data.append(tmp) tmp[1] <= q tmp[1] tmp 1 q time_count += tmp[1] time_count tmp[1] tmp 1 dt_out.append([tmp[0],time_count]) dt_out.append dt_out append [tmp[0],time_count] tmp[0] tmp 0 time_count tmp[1] -= q tmp[1] tmp 1 q time_count += q time_count q data.append(tmp) data.append data append tmp for tmp in dt_out:
    print(tmp[0]+" "+str(tmp[1])) tmp dt_out print(tmp[0]+" "+str(tmp[1])) print tmp[0]+" "+str(tmp[1]) tmp[0]+" " tmp[0] tmp 0 " " str(tmp[1]) str tmp[1] tmp 1 time_count = 0 0 time_count dt_out = [] [] dt_out n, q = map(int, input().split()) map(int, input().split()) n tmp = data.pop(0) data.pop(0) tmp q = map(int, input().split()) map(int, input().split()) q time_count += q q time_count data = [] [] data time_count += tmp[1] tmp[1] time_count tmp = input().split() input().split() tmp
n, q = map(int, input().split())
data = []
for i in range(n):
    tmp = input().split()
    tmp[1] = int(tmp[1])
    data.append(tmp)

dt_out = []
time_count = 0

while len(data) > 0 :
    tmp = data.pop(0)
    if(tmp[1] <= q):
        time_count += tmp[1]
        dt_out.append([tmp[0],time_count])
    else:
        tmp[1] -= q
        time_count += q
        data.append(tmp)

for tmp in dt_out:
    print(tmp[0]+" "+str(tmp[1]))