# coding=utf-8
from collections import deque

n, q = map(int, input().split())
queue = deque()
total_time = 0

for i in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while queue:
    poped = queue.popleft()
    if poped[1] > q:
        queue.append([poped[0], poped[1] - q])
        total_time += q
    else:
        total_time += poped[1]
        print(poped[0], total_time) from collections import deque n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q queue = deque() queue deque() deque total_time = 0 total_time 0 for i in range(n):
    name, time = input().split()
    queue.append([name, int(time)]) i range(n) range n name, time = input().split() name input().split() ().split () input split time queue.append([name, int(time)]) queue.append queue append [name, int(time)] name int(time) int time while queue:
    poped = queue.popleft()
    if poped[1] > q:
        queue.append([poped[0], poped[1] - q])
        total_time += q
    else:
        total_time += poped[1]
        print(poped[0], total_time) queue poped = queue.popleft() poped queue.popleft() queue.popleft queue popleft if poped[1] > q:
        queue.append([poped[0], poped[1] - q])
        total_time += q
    else:
        total_time += poped[1]
        print(poped[0], total_time) poped[1] > q poped[1] poped 1 q queue.append([poped[0], poped[1] - q]) queue.append queue append [poped[0], poped[1] - q] poped[0] poped 0 poped[1] - q poped[1] poped 1 q total_time += q total_time q total_time += poped[1] total_time poped[1] poped 1 print(poped[0], total_time) print poped[0] poped 0 total_time time = input().split() input().split() time poped = queue.popleft() queue.popleft() poped queue = deque() deque() queue total_time += q q total_time name, time = input().split() input().split() name total_time += poped[1] poped[1] total_time n, q = map(int, input().split()) map(int, input().split()) n total_time = 0 0 total_time q = map(int, input().split()) map(int, input().split()) q
# coding=utf-8
from collections import deque

n, q = map(int, input().split())
queue = deque()
total_time = 0

for i in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while queue:
    poped = queue.popleft()
    if poped[1] > q:
        queue.append([poped[0], poped[1] - q])
        total_time += q
    else:
        total_time += poped[1]
        print(poped[0], total_time)