import sys
data = []
for line in sys.stdin:
	data.append(line.split())

quontum = int(data[0][1])
targetData = data[1:]
answerData = []
totalQuontum = 0

while targetData :
	target = targetData.pop(0)

	target[1] =  int(target[1]) - quontum

	if target[1]<= 0:
		totalQuontum += quontum + int(target[1])
		target[1] = totalQuontum
		answerData.append(target)
	else :
		targetData.append(target)
		totalQuontum += quontum

for answer in answerData:
	print(str(answer[0]) + ' ' + str(answer[1])) import sys sys data = [] data [] for line in sys.stdin:
	data.append(line.split()) line sys.stdin sys stdin data.append(line.split()) data.append data append line.split() line.split line split quontum = int(data[0][1]) quontum int(data[0][1]) int data[0][1] [0] data 0 1 targetData = data[1:] targetData data[1:] data 1: 1 answerData = [] answerData [] totalQuontum = 0 totalQuontum 0 while targetData :
	target = targetData.pop(0)

	target[1] =  int(target[1]) - quontum

	if target[1]<= 0:
		totalQuontum += quontum + int(target[1])
		target[1] = totalQuontum
		answerData.append(target)
	else :
		targetData.append(target)
		totalQuontum += quontum targetData target = targetData.pop(0) target targetData.pop(0) targetData.pop targetData pop 0 target[1] =  int(target[1]) - quontum target[1] target 1 int(target[1]) - quontum int(target[1]) int target[1] target 1 quontum if target[1]<= 0:
		totalQuontum += quontum + int(target[1])
		target[1] = totalQuontum
		answerData.append(target)
	else :
		targetData.append(target)
		totalQuontum += quontum target[1]<= 0 target[1] target 1 0 totalQuontum += quontum + int(target[1]) totalQuontum quontum + int(target[1]) quontum int(target[1]) int target[1] target 1 target[1] = totalQuontum target[1] target 1 totalQuontum answerData.append(target) answerData.append answerData append target targetData.append(target) targetData.append targetData append target totalQuontum += quontum totalQuontum quontum for answer in answerData:
	print(str(answer[0]) + ' ' + str(answer[1])) answer answerData print(str(answer[0]) + ' ' + str(answer[1])) print str(answer[0]) + ' ' + str(answer[1]) str(answer[0]) + ' ' str(answer[0]) str answer[0] answer 0 ' ' str(answer[1]) str answer[1] answer 1 answerData = [] [] answerData totalQuontum += quontum + int(target[1]) quontum + int(target[1]) totalQuontum totalQuontum = 0 0 totalQuontum totalQuontum += quontum quontum totalQuontum targetData = data[1:] data[1:] targetData data = [] [] data quontum = int(data[0][1]) int(data[0][1]) quontum target = targetData.pop(0) targetData.pop(0) target
import sys
data = []
for line in sys.stdin:
	data.append(line.split())

quontum = int(data[0][1])
targetData = data[1:]
answerData = []
totalQuontum = 0

while targetData :
	target = targetData.pop(0)

	target[1] =  int(target[1]) - quontum

	if target[1]<= 0:
		totalQuontum += quontum + int(target[1])
		target[1] = totalQuontum
		answerData.append(target)
	else :
		targetData.append(target)
		totalQuontum += quontum

for answer in answerData:
	print(str(answer[0]) + ' ' + str(answer[1]))
