import collections
import sys

n,q = map(int,input().split())
data = [[i for i in input().split()]for i in range(n)]
time = 0
while data:
    task = data[0]
    del data[0]
    if int(task[1]) <= q:
        time += int(task[1])
        print(task[0],time)
      
    else:
        time += q
        task[1] = str(int(task[1]) - q)
        data.append(task) import collections collections import sys sys n,q = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split q [i for i in input().split()]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [i for i in input().split()] data = [[i for i in input().split()]for i in range(n)] data [[i for i in input().split()]for i in range(n)] time = 0 time 0 while data:
    task = data[0]
    del data[0]
    if int(task[1]) <= q:
        time += int(task[1])
        print(task[0],time)
      
    else:
        time += q
        task[1] = str(int(task[1]) - q)
        data.append(task) data task = data[0] task data[0] data 0 del data[0] data[0] data 0 if int(task[1]) <= q:
        time += int(task[1])
        print(task[0],time)
      
    else:
        time += q
        task[1] = str(int(task[1]) - q)
        data.append(task) int(task[1]) <= q int(task[1]) int task[1] task 1 q time += int(task[1]) time int(task[1]) int task[1] task 1 print(task[0],time) print task[0] task 0 time time += q time q task[1] = str(int(task[1]) - q) task[1] task 1 str(int(task[1]) - q) str int(task[1]) - q int(task[1]) int task[1] task 1 q data.append(task) data.append data append task q = map(int,input().split()) map(int,input().split()) q n,q = map(int,input().split()) map(int,input().split()) n time += q q time task = data[0] data[0] task time = 0 0 time time += int(task[1]) int(task[1]) time data = [[i for i in input().split()]for i in range(n)] [[i for i in input().split()]for i in range(n)] data
import collections
import sys

n,q = map(int,input().split())
data = [[i for i in input().split()]for i in range(n)]
time = 0
while data:
    task = data[0]
    del data[0]
    if int(task[1]) <= q:
        time += int(task[1])
        print(task[0],time)
      
    else:
        time += q
        task[1] = str(int(task[1]) - q)
        data.append(task)