
pnum,mtime = map(int,input().split(" "))

total = [list(input().split(" ")) for _ in range(pnum)]

cnt=0
tcnt=0
while len(total) > 0:
	ztime = int(total[0][1]) - mtime
	if ztime <= 0:
		tcnt += int(total[0][1])
		print(total[0][0],int(tcnt))
		total.pop(0)
	else:
		total.append([total[0][0],ztime])
		total.pop(0)
		tcnt += mtime
	cnt += 1
 pnum,mtime = map(int,input().split(" ")) pnum map(int,input().split(" ")) map int input().split(" ") ().split () input split " " mtime list(input().split(" ")) for _ in range(pnum) for _ in range(pnum) _ range(pnum) range pnum for _ in range(pnum) list(input().split(" ")) list input().split(" ") ().split () input split " " total = [list(input().split(" ")) for _ in range(pnum)] total [list(input().split(" ")) for _ in range(pnum)] cnt=0 cnt 0 tcnt=0 tcnt 0 while len(total) > 0:
	ztime = int(total[0][1]) - mtime
	if ztime <= 0:
		tcnt += int(total[0][1])
		print(total[0][0],int(tcnt))
		total.pop(0)
	else:
		total.append([total[0][0],ztime])
		total.pop(0)
		tcnt += mtime
	cnt += 1 len(total) > 0 len(total) len total 0 ztime = int(total[0][1]) - mtime ztime int(total[0][1]) - mtime int(total[0][1]) int total[0][1] [0] total 0 1 mtime if ztime <= 0:
		tcnt += int(total[0][1])
		print(total[0][0],int(tcnt))
		total.pop(0)
	else:
		total.append([total[0][0],ztime])
		total.pop(0)
		tcnt += mtime
	 ztime <= 0 ztime 0 tcnt += int(total[0][1]) tcnt int(total[0][1]) int total[0][1] [0] total 0 1 print(total[0][0],int(tcnt)) print total[0][0] [0] total 0 0 int(tcnt) int tcnt total.pop(0) total.pop total pop 0 total.append([total[0][0],ztime]) total.append total append [total[0][0],ztime] total[0][0] [0] total 0 0 ztime total.pop(0) total.pop total pop 0 tcnt += mtime tcnt mtime cnt += 1 cnt 1 tcnt += int(total[0][1]) int(total[0][1]) tcnt mtime = map(int,input().split(" ")) map(int,input().split(" ")) mtime total = [list(input().split(" ")) for _ in range(pnum)] [list(input().split(" ")) for _ in range(pnum)] total ztime = int(total[0][1]) - mtime int(total[0][1]) - mtime ztime tcnt += mtime mtime tcnt cnt += 1 1 cnt tcnt=0 0 tcnt cnt=0 0 cnt pnum,mtime = map(int,input().split(" ")) map(int,input().split(" ")) pnum

pnum,mtime = map(int,input().split(" "))

total = [list(input().split(" ")) for _ in range(pnum)]

cnt=0
tcnt=0
while len(total) > 0:
	ztime = int(total[0][1]) - mtime
	if ztime <= 0:
		tcnt += int(total[0][1])
		print(total[0][0],int(tcnt))
		total.pop(0)
	else:
		total.append([total[0][0],ztime])
		total.pop(0)
		tcnt += mtime
	cnt += 1

