sch = []
fin = []
total = 0
cnt,time = map(int,input().split())

for i in range(cnt):
    n,t = input().split()
    sch.append([n,int(t)])

while len(sch) > 0:
    if sch[0][1] <= time:
        total += sch[0][1]
        v = sch.pop(0)
        fin.append([v[0],total])
    else:
        total += time
        sch[0][1] -= time
        last = sch.pop(0)
        sch.append(last)

for i in range(len(fin)):
    print("{0} {1}".format(fin[i][0],fin[i][1])) sch = [] sch [] fin = [] fin [] total = 0 total 0 cnt,time = map(int,input().split()) cnt map(int,input().split()) map int input().split() ().split () input split time for i in range(cnt):
    n,t = input().split()
    sch.append([n,int(t)]) i range(cnt) range cnt n,t = input().split() n input().split() ().split () input split t sch.append([n,int(t)]) sch.append sch append [n,int(t)] n int(t) int t while len(sch) > 0:
    if sch[0][1] <= time:
        total += sch[0][1]
        v = sch.pop(0)
        fin.append([v[0],total])
    else:
        total += time
        sch[0][1] -= time
        last = sch.pop(0)
        sch.append(last) len(sch) > 0 len(sch) len sch 0 if sch[0][1] <= time:
        total += sch[0][1]
        v = sch.pop(0)
        fin.append([v[0],total])
    else:
        total += time
        sch[0][1] -= time
        last = sch.pop(0)
        sch.append(last) sch[0][1] <= time sch[0][1] [0] sch 0 1 time total += sch[0][1] total sch[0][1] [0] sch 0 1 v = sch.pop(0) v sch.pop(0) sch.pop sch pop 0 fin.append([v[0],total]) fin.append fin append [v[0],total] v[0] v 0 total total += time total time sch[0][1] -= time sch[0][1] [0] sch 0 1 time last = sch.pop(0) last sch.pop(0) sch.pop sch pop 0 sch.append(last) sch.append sch append last for i in range(len(fin)):
    print("{0} {1}".format(fin[i][0],fin[i][1])) i range(len(fin)) range len(fin) len fin print("{0} {1}".format(fin[i][0],fin[i][1])) print "{0} {1}".format(fin[i][0],fin[i][1]) "{0} {1}".format "{0} {1}" format fin[i][0] [i] fin i 0 fin[i][1] [i] fin i 1 cnt,time = map(int,input().split()) map(int,input().split()) cnt total = 0 0 total time = map(int,input().split()) map(int,input().split()) time t = input().split() input().split() t n,t = input().split() input().split() n fin = [] [] fin total += sch[0][1] sch[0][1] total last = sch.pop(0) sch.pop(0) last sch = [] [] sch total += time time total v = sch.pop(0) sch.pop(0) v
sch = []
fin = []
total = 0
cnt,time = map(int,input().split())

for i in range(cnt):
    n,t = input().split()
    sch.append([n,int(t)])

while len(sch) > 0:
    if sch[0][1] <= time:
        total += sch[0][1]
        v = sch.pop(0)
        fin.append([v[0],total])
    else:
        total += time
        sch[0][1] -= time
        last = sch.pop(0)
        sch.append(last)

for i in range(len(fin)):
    print("{0} {1}".format(fin[i][0],fin[i][1]))