n, q = [int(i) for i in input().split()]
que = []
ans_count = 0 #出力数
time = 0 #経過時間
# data読み込み
for i in range(n):
    que.append([i for i in input().split()])

while(ans_count!=n):
    pop_process = que.pop(0)
    pop_process[1] = int(pop_process[1])
    # 末尾から追加、先頭から取り出す
    if pop_process[1] <= q:
        time += pop_process[1]
        print('{0} {1}'.format(pop_process[0], time))
        ans_count += 1
    else:
        time += q
        pop_process[1] -= q
        que.append(pop_process) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n, q = [int(i) for i in input().split()] n [int(i) for i in input().split()] q que = [] que [] ans_count = 0 ans_count 0 time = 0 time 0 for i in range(n):
    que.append([i for i in input().split()]) i range(n) range n i for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() i que.append([i for i in input().split()]) que.append que append [i for i in input().split()] while(ans_count!=n):
    pop_process = que.pop(0)
    pop_process[1] = int(pop_process[1])
    # 末尾から追加、先頭から取り出す
    if pop_process[1] <= q:
        time += pop_process[1]
        print('{0} {1}'.format(pop_process[0], time))
        ans_count += 1
    else:
        time += q
        pop_process[1] -= q
        que.append(pop_process) ans_count!=n ans_count n pop_process = que.pop(0) pop_process que.pop(0) que.pop que pop 0 pop_process[1] = int(pop_process[1]) pop_process[1] pop_process 1 int(pop_process[1]) int pop_process[1] pop_process 1 if pop_process[1] <= q:
        time += pop_process[1]
        print('{0} {1}'.format(pop_process[0], time))
        ans_count += 1
    else:
        time += q
        pop_process[1] -= q
        que.append(pop_process) pop_process[1] <= q pop_process[1] pop_process 1 q time += pop_process[1] time pop_process[1] pop_process 1 print('{0} {1}'.format(pop_process[0], time)) print '{0} {1}'.format(pop_process[0], time) '{0} {1}'.format '{0} {1}' format pop_process[0] pop_process 0 time ans_count += 1 ans_count 1 time += q time q pop_process[1] -= q pop_process[1] pop_process 1 q que.append(pop_process) que.append que append pop_process time = 0 0 time q = [int(i) for i in input().split()] [int(i) for i in input().split()] q n, q = [int(i) for i in input().split()] [int(i) for i in input().split()] n ans_count = 0 0 ans_count ans_count += 1 1 ans_count time += pop_process[1] pop_process[1] time que = [] [] que pop_process = que.pop(0) que.pop(0) pop_process time += q q time
n, q = [int(i) for i in input().split()]
que = []
ans_count = 0 #出力数
time = 0 #経過時間
# data読み込み
for i in range(n):
    que.append([i for i in input().split()])

while(ans_count!=n):
    pop_process = que.pop(0)
    pop_process[1] = int(pop_process[1])
    # 末尾から追加、先頭から取り出す
    if pop_process[1] <= q:
        time += pop_process[1]
        print('{0} {1}'.format(pop_process[0], time))
        ans_count += 1
    else:
        time += q
        pop_process[1] -= q
        que.append(pop_process)
