n,q = map(int, input().split())
a = []
t = 0
for i in range(n):
    a.append(input().split())
 
while len(a) != 0:
    A =  a.pop(0)
    if int(A[1]) <= q:
        t += int(A[1])
        print(A[0],t)
    else:
        t += q
        A[1] = int(A[1]) - q
        a.append(A) n,q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q a = [] a [] t = 0 t 0 for i in range(n):
    a.append(input().split())
  i range(n) range n a.append(input().split()) a.append a append input().split() ().split () input split while len(a) != 0:
    A =  a.pop(0)
    if int(A[1]) <= q:
        t += int(A[1])
        print(A[0],t)
    else:
        t += q
        A[1] = int(A[1]) - q
        a.append(A) len(a) != 0 len(a) len a 0 A =  a.pop(0) A a.pop(0) a.pop a pop 0 if int(A[1]) <= q:
        t += int(A[1])
        print(A[0],t)
    else:
        t += q
        A[1] = int(A[1]) - q
        a.append(A) int(A[1]) <= q int(A[1]) int A[1] A 1 q t += int(A[1]) t int(A[1]) int A[1] A 1 print(A[0],t) print A[0] A 0 t t += q t q A[1] = int(A[1]) - q A[1] A 1 int(A[1]) - q int(A[1]) int A[1] A 1 q a.append(A) a.append a append A t += q q t a = [] [] a A =  a.pop(0) a.pop(0) A n,q = map(int, input().split()) map(int, input().split()) n q = map(int, input().split()) map(int, input().split()) q t = 0 0 t t += int(A[1]) int(A[1]) t
n,q = map(int, input().split())
a = []
t = 0
for i in range(n):
    a.append(input().split())
 
while len(a) != 0:
    A =  a.pop(0)
    if int(A[1]) <= q:
        t += int(A[1])
        print(A[0],t)
    else:
        t += q
        A[1] = int(A[1]) - q
        a.append(A)
