sum=0
s=0
A=input().split()
n=(int)(A[0])
t=(int)(A[1])
x=[0 for i in range(2*n)]
for i in range(n):
    B=input().split()
    k=2*i
    x[k]=(B[0])
    x[k+1]=(int)(B[1])
while len(x)>0:
    s=x[1]-t
    if s>0: 
        sum+=t
        x.append(x[0])
        x.append(s)
        del x[0]
        del x[0]
    if s<=0:
        sum+=x[1]
        print( x[0],sum)
        del x[0]
        del x[0]
 sum=0 sum 0 s=0 s 0 A=input().split() A input().split() ().split () input split n=(int)(A[0]) n (int)(A[0]) int A[0] A 0 t=(int)(A[1]) t (int)(A[1]) int A[1] A 1 0 for i in range(2*n) for i in range(2*n) i range(2*n) range 2*n 2 n for i in range(2*n) 0 x=[0 for i in range(2*n)] x [0 for i in range(2*n)] for i in range(n):
    B=input().split()
    k=2*i
    x[k]=(B[0])
    x[k+1]=(int)(B[1]) i range(n) range n B=input().split() B input().split() ().split () input split k=2*i k 2*i 2 i x[k]=(B[0]) x[k] x k B[0] B 0 x[k+1]=(int)(B[1]) x[k+1] x k+1 k 1 (int)(B[1]) int B[1] B 1 while len(x)>0:
    s=x[1]-t
    if s>0: 
        sum+=t
        x.append(x[0])
        x.append(s)
        del x[0]
        del x[0]
    if s<=0:
        sum+=x[1]
        print( x[0],sum)
        del x[0]
        del x[0] len(x)>0 len(x) len x 0 s=x[1]-t s x[1]-t x[1] x 1 t if s>0: 
        sum+=t
        x.append(x[0])
        x.append(s)
        del x[0]
        del x[0]
     s>0 s 0 sum+=t sum t x.append(x[0]) x.append x append x[0] x 0 x.append(s) x.append x append s del x[0] x[0] x 0 del x[0] x[0] x 0 if s<=0:
        sum+=x[1]
        print( x[0],sum)
        del x[0]
        del x[0] s<=0 s 0 sum+=x[1] sum x[1] x 1 print( x[0],sum) print x[0] x 0 sum del x[0] x[0] x 0 del x[0] x[0] x 0 B=input().split() input().split() B sum+=x[1] x[1] sum k=2*i 2*i k x=[0 for i in range(2*n)] [0 for i in range(2*n)] x s=x[1]-t x[1]-t s A=input().split() input().split() A t=(int)(A[1]) (int)(A[1]) t sum+=t t sum sum=0 0 sum s=0 0 s n=(int)(A[0]) (int)(A[0]) n
sum=0
s=0
A=input().split()
n=(int)(A[0])
t=(int)(A[1])
x=[0 for i in range(2*n)]
for i in range(n):
    B=input().split()
    k=2*i
    x[k]=(B[0])
    x[k+1]=(int)(B[1])
while len(x)>0:
    s=x[1]-t
    if s>0: 
        sum+=t
        x.append(x[0])
        x.append(s)
        del x[0]
        del x[0]
    if s<=0:
        sum+=x[1]
        print( x[0],sum)
        del x[0]
        del x[0]

