n,q = map(int,raw_input().split(" "))
task = [raw_input().split(" ") for i in range(n)]
c= 0
while task:
	name,time = task.pop(0)
	e = int(time) - q
	if e > 0:
		c+= q
		task.append([name,e])
	else:
		c+= int(time)
		print name+" "+str(c) n,q = map(int,raw_input().split(" ")) n map(int,raw_input().split(" ")) map int raw_input().split(" ") ().split () raw_input split " " q raw_input().split(" ") for i in range(n) for i in range(n) i range(n) range n for i in range(n) raw_input().split(" ") ().split () raw_input split " " task = [raw_input().split(" ") for i in range(n)] task [raw_input().split(" ") for i in range(n)] c= 0 c 0 while task:
	name,time = task.pop(0)
	e = int(time) - q
	if e > 0:
		c+= q
		task.append([name,e])
	else:
		c+= int(time)
		print name+" "+str(c) task name,time = task.pop(0) name task.pop(0) task.pop task pop 0 time e = int(time) - q e int(time) - q int(time) int time q if e > 0:
		c+= q
		task.append([name,e])
	else:
		c+= int(time)
		print name+" "+str(c) e > 0 e 0 c+= q c q task.append([name,e]) task.append task append [name,e] name e c+= int(time) c int(time) int time print name+" "+str(c) name+" " name " " str(c) str c time = task.pop(0) task.pop(0) time task = [raw_input().split(" ") for i in range(n)] [raw_input().split(" ") for i in range(n)] task c= 0 0 c n,q = map(int,raw_input().split(" ")) map(int,raw_input().split(" ")) n name,time = task.pop(0) task.pop(0) name e = int(time) - q int(time) - q e c+= int(time) int(time) c c+= q q c q = map(int,raw_input().split(" ")) map(int,raw_input().split(" ")) q
n,q = map(int,raw_input().split(" "))
task = [raw_input().split(" ") for i in range(n)]
c= 0
while task:
	name,time = task.pop(0)
	e = int(time) - q
	if e > 0:
		c+= q
		task.append([name,e])
	else:
		c+= int(time)
		print name+" "+str(c)