n, q = list(map(int, input().split()))
works = []
for i in range(n):
    works.append(list(input().split()))

count = 0
while len(works) != 0:
    work = works.pop(0)
    time = int(work[1])
    if time > q:
        count += q
        work[1] = time - q
        works.append(work)
    else:
        count += time
        print(work[0] , count) n, q = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split q works = [] works [] for i in range(n):
    works.append(list(input().split())) i range(n) range n works.append(list(input().split())) works.append works append list(input().split()) list input().split() ().split () input split count = 0 count 0 while len(works) != 0:
    work = works.pop(0)
    time = int(work[1])
    if time > q:
        count += q
        work[1] = time - q
        works.append(work)
    else:
        count += time
        print(work[0] , count) len(works) != 0 len(works) len works 0 work = works.pop(0) work works.pop(0) works.pop works pop 0 time = int(work[1]) time int(work[1]) int work[1] work 1 if time > q:
        count += q
        work[1] = time - q
        works.append(work)
    else:
        count += time
        print(work[0] , count) time > q time q count += q count q work[1] = time - q work[1] work 1 time - q time q works.append(work) works.append works append work count += time count time print(work[0] , count) print work[0] work 0 count works = [] [] works q = list(map(int, input().split())) list(map(int, input().split())) q count = 0 0 count time = int(work[1]) int(work[1]) time count += time time count work = works.pop(0) works.pop(0) work count += q q count n, q = list(map(int, input().split())) list(map(int, input().split())) n
n, q = list(map(int, input().split()))
works = []
for i in range(n):
    works.append(list(input().split()))

count = 0
while len(works) != 0:
    work = works.pop(0)
    time = int(work[1])
    if time > q:
        count += q
        work[1] = time - q
        works.append(work)
    else:
        count += time
        print(work[0] , count)