from queue import Queue
n, q = map(int, input().split())
que = Queue()
for i in range(n):
    name, time = input().split()
    que.put((name, int(time)))

total = 0
while que.qsize() > 0:
    name, time = que.get()
    total += min(q, time)
    if q < time:
        que.put((name, time-q))
    else:
        print(name, total) from queue import Queue n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q que = Queue() que Queue() Queue for i in range(n):
    name, time = input().split()
    que.put((name, int(time))) i range(n) range n name, time = input().split() name input().split() ().split () input split time que.put((name, int(time))) que.put que put (name, int(time)) name int(time) int time total = 0 total 0 while que.qsize() > 0:
    name, time = que.get()
    total += min(q, time)
    if q < time:
        que.put((name, time-q))
    else:
        print(name, total) que.qsize() > 0 que.qsize() que.qsize que qsize 0 name, time = que.get() name que.get() que.get que get time total += min(q, time) total min(q, time) min q time if q < time:
        que.put((name, time-q))
    else:
        print(name, total) q < time q time que.put((name, time-q)) que.put que put (name, time-q) name time-q time q print(name, total) print name total que = Queue() Queue() que name, time = input().split() input().split() name total += min(q, time) min(q, time) total total = 0 0 total time = que.get() que.get() time n, q = map(int, input().split()) map(int, input().split()) n name, time = que.get() que.get() name time = input().split() input().split() time q = map(int, input().split()) map(int, input().split()) q
from queue import Queue
n, q = map(int, input().split())
que = Queue()
for i in range(n):
    name, time = input().split()
    que.put((name, int(time)))

total = 0
while que.qsize() > 0:
    name, time = que.get()
    total += min(q, time)
    if q < time:
        que.put((name, time-q))
    else:
        print(name, total)