#python2.7
N,M = raw_input().split()
time=0
flag=1
A=[]
for i in range(int(N)):
	A.append(raw_input().split())

while len(A)!=0:
	if(int(A[0][1])>int(M)):
		A[0][1]=str(int(A[0][1])-int(M))
		A.append(A[0])
		del A[0]
		time+=int(M)
	else:
		time+=int(A[0][1])
		print A[0][0]+" "+str(time)
		del A[0] N,M = raw_input().split() N raw_input().split() ().split () raw_input split M time=0 time 0 flag=1 flag 1 A=[] A [] for i in range(int(N)):
	A.append(raw_input().split()) i range(int(N)) range int(N) int N A.append(raw_input().split()) A.append A append raw_input().split() ().split () raw_input split while len(A)!=0:
	if(int(A[0][1])>int(M)):
		A[0][1]=str(int(A[0][1])-int(M))
		A.append(A[0])
		del A[0]
		time+=int(M)
	else:
		time+=int(A[0][1])
		print A[0][0]+" "+str(time)
		del A[0] len(A)!=0 len(A) len A 0 if(int(A[0][1])>int(M)):
		A[0][1]=str(int(A[0][1])-int(M))
		A.append(A[0])
		del A[0]
		time+=int(M)
	else:
		time+=int(A[0][1])
		print A[0][0]+" "+str(time)
		del A[0] int(A[0][1])>int(M) int(A[0][1]) int A[0][1] [0] A 0 1 int(M) int M A[0][1]=str(int(A[0][1])-int(M)) A[0][1] [0] A 0 1 str(int(A[0][1])-int(M)) str int(A[0][1])-int(M) int(A[0][1]) int A[0][1] [0] A 0 1 int(M) int M A.append(A[0]) A.append A append A[0] A 0 del A[0] A[0] A 0 time+=int(M) time int(M) int M time+=int(A[0][1]) time int(A[0][1]) int A[0][1] [0] A 0 1 print A[0][0]+" "+str(time) A[0][0]+" " A[0][0] [0] A 0 0 " " str(time) str time del A[0] A[0] A 0 N,M = raw_input().split() raw_input().split() N A=[] [] A time+=int(A[0][1]) int(A[0][1]) time M = raw_input().split() raw_input().split() M time=0 0 time flag=1 1 flag time+=int(M) int(M) time
#python2.7
N,M = raw_input().split()
time=0
flag=1
A=[]
for i in range(int(N)):
	A.append(raw_input().split())

while len(A)!=0:
	if(int(A[0][1])>int(M)):
		A[0][1]=str(int(A[0][1])-int(M))
		A.append(A[0])
		del A[0]
		time+=int(M)
	else:
		time+=int(A[0][1])
		print A[0][0]+" "+str(time)
		del A[0]