N_str, q_str = raw_input().split()
N = int(N_str)
q = int(q_str)
A =[]
B =[]
total =0

for i in range(N):
    t = raw_input().split()
    A.append([t[0],int(t[1])])

while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time])

print '\n'.join(B) N_str, q_str = raw_input().split() N_str raw_input().split() ().split () raw_input split q_str N = int(N_str) N int(N_str) int N_str q = int(q_str) q int(q_str) int q_str A =[] A [] B =[] B [] total =0 total 0 for i in range(N):
    t = raw_input().split()
    A.append([t[0],int(t[1])]) i range(N) range N t = raw_input().split() t raw_input().split() ().split () raw_input split A.append([t[0],int(t[1])]) A.append A append [t[0],int(t[1])] t[0] t 0 int(t[1]) int t[1] t 1 while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time]) A name, time = A.pop(0) name A.pop(0) A.pop A pop 0 time if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time]) time <= q time q total += time total time B.append(name+" "+ str(total)) B.append B append name+" "+ str(total) name+" " name " " str(total) str total time -= q time q total += q total q A.append([name, time]) A.append A append [name, time] name time print '\n'.join(B) '\n'.join '\n' join B total += q q total N = int(N_str) int(N_str) N q_str = raw_input().split() raw_input().split() q_str total =0 0 total N_str, q_str = raw_input().split() raw_input().split() N_str time -= q q time name, time = A.pop(0) A.pop(0) name time = A.pop(0) A.pop(0) time t = raw_input().split() raw_input().split() t q = int(q_str) int(q_str) q total += time time total A =[] [] A B =[] [] B
N_str, q_str = raw_input().split()
N = int(N_str)
q = int(q_str)
A =[]
B =[]
total =0

for i in range(N):
    t = raw_input().split()
    A.append([t[0],int(t[1])])

while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time])

print '\n'.join(B)