n, q = map(int, input().split())
queue = []
for i in range(n):
    x = input().split()
    queue.append((x[0], int(x[1])))
time = 0
while queue != []:
    if queue[0][1] <= q:
        time += queue[0][1]
        print('{} {}'.format(queue.pop(0)[0], time))
    else:
        time += q
        x = queue.pop(0)
        queue.append((x[0], x[1]-q)) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q queue = [] queue [] for i in range(n):
    x = input().split()
    queue.append((x[0], int(x[1]))) i range(n) range n x = input().split() x input().split() ().split () input split queue.append((x[0], int(x[1]))) queue.append queue append (x[0], int(x[1])) x[0] x 0 int(x[1]) int x[1] x 1 time = 0 time 0 while queue != []:
    if queue[0][1] <= q:
        time += queue[0][1]
        print('{} {}'.format(queue.pop(0)[0], time))
    else:
        time += q
        x = queue.pop(0)
        queue.append((x[0], x[1]-q)) queue != [] queue [] if queue[0][1] <= q:
        time += queue[0][1]
        print('{} {}'.format(queue.pop(0)[0], time))
    else:
        time += q
        x = queue.pop(0)
        queue.append((x[0], x[1]-q)) queue[0][1] <= q queue[0][1] [0] queue 0 1 q time += queue[0][1] time queue[0][1] [0] queue 0 1 print('{} {}'.format(queue.pop(0)[0], time)) print '{} {}'.format(queue.pop(0)[0], time) '{} {}'.format '{} {}' format queue.pop(0)[0] queue.pop(0) queue.pop queue pop 0 0 time time += q time q x = queue.pop(0) x queue.pop(0) queue.pop queue pop 0 queue.append((x[0], x[1]-q)) queue.append queue append (x[0], x[1]-q) x[0] x 0 x[1]-q x[1] x 1 q n, q = map(int, input().split()) map(int, input().split()) n queue = [] [] queue time = 0 0 time q = map(int, input().split()) map(int, input().split()) q x = input().split() input().split() x time += q q time time += queue[0][1] queue[0][1] time x = queue.pop(0) queue.pop(0) x
n, q = map(int, input().split())
queue = []
for i in range(n):
    x = input().split()
    queue.append((x[0], int(x[1])))
time = 0
while queue != []:
    if queue[0][1] <= q:
        time += queue[0][1]
        print('{} {}'.format(queue.pop(0)[0], time))
    else:
        time += q
        x = queue.pop(0)
        queue.append((x[0], x[1]-q))
