n, q = list(map(int, input().split()))
que = []

for i in range(n):
    p, t = input().split()
    que.append([p, int(t)])

total = 0
while True:
    if q >= que[0][1]:
        total += que[0][1]
        print(que[0][0], total)
        que.pop(0)
    else:
        total += q
        que[0][1] -= q
        que.append(que[0])
        que.pop(0)
    if len(que) == 0:
        break
 n, q = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split q que = [] que [] for i in range(n):
    p, t = input().split()
    que.append([p, int(t)]) i range(n) range n p, t = input().split() p input().split() ().split () input split t que.append([p, int(t)]) que.append que append [p, int(t)] p int(t) int t total = 0 total 0 while True:
    if q >= que[0][1]:
        total += que[0][1]
        print(que[0][0], total)
        que.pop(0)
    else:
        total += q
        que[0][1] -= q
        que.append(que[0])
        que.pop(0)
    if len(que) == 0:
        break True if q >= que[0][1]:
        total += que[0][1]
        print(que[0][0], total)
        que.pop(0)
    else:
        total += q
        que[0][1] -= q
        que.append(que[0])
        que.pop(0)
     q >= que[0][1] q que[0][1] [0] que 0 1 total += que[0][1] total que[0][1] [0] que 0 1 print(que[0][0], total) print que[0][0] [0] que 0 0 total que.pop(0) que.pop que pop 0 total += q total q que[0][1] -= q que[0][1] [0] que 0 1 q que.append(que[0]) que.append que append que[0] que 0 que.pop(0) que.pop que pop 0 if len(que) == 0:
        break len(que) == 0 len(que) len que 0 break n, q = list(map(int, input().split())) list(map(int, input().split())) n total += q q total que = [] [] que total = 0 0 total p, t = input().split() input().split() p q = list(map(int, input().split())) list(map(int, input().split())) q t = input().split() input().split() t total += que[0][1] que[0][1] total
n, q = list(map(int, input().split()))
que = []

for i in range(n):
    p, t = input().split()
    que.append([p, int(t)])

total = 0
while True:
    if q >= que[0][1]:
        total += que[0][1]
        print(que[0][0], total)
        que.pop(0)
    else:
        total += q
        que[0][1] -= q
        que.append(que[0])
        que.pop(0)
    if len(que) == 0:
        break

