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

now = 0
while len(que) != 0:
    if que[0][1] > q:
        que[0][1] -= q
        now += q
        que.append(que.pop(0))
    else:
        now += que[0][1]
        print("{} {}".format(que[0][0], now))
        que.pop(0) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q que = [] que [] for _ in range(n):
    p, t = input().split()
    que.append([p, int(t)]) _ 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 now = 0 now 0 while len(que) != 0:
    if que[0][1] > q:
        que[0][1] -= q
        now += q
        que.append(que.pop(0))
    else:
        now += que[0][1]
        print("{} {}".format(que[0][0], now))
        que.pop(0) len(que) != 0 len(que) len que 0 if que[0][1] > q:
        que[0][1] -= q
        now += q
        que.append(que.pop(0))
    else:
        now += que[0][1]
        print("{} {}".format(que[0][0], now))
        que.pop(0) que[0][1] > q que[0][1] [0] que 0 1 q que[0][1] -= q que[0][1] [0] que 0 1 q now += q now q que.append(que.pop(0)) que.append que append que.pop(0) que.pop que pop 0 now += que[0][1] now que[0][1] [0] que 0 1 print("{} {}".format(que[0][0], now)) print "{} {}".format(que[0][0], now) "{} {}".format "{} {}" format que[0][0] [0] que 0 0 now que.pop(0) que.pop que pop 0 n, q = map(int, input().split()) map(int, input().split()) n q = map(int, input().split()) map(int, input().split()) q p, t = input().split() input().split() p now = 0 0 now t = input().split() input().split() t que = [] [] que now += q q now now += que[0][1] que[0][1] now
n, q = map(int, input().split())
que = []
for _ in range(n):
    p, t = input().split()
    que.append([p, int(t)])

now = 0
while len(que) != 0:
    if que[0][1] > q:
        que[0][1] -= q
        now += q
        que.append(que.pop(0))
    else:
        now += que[0][1]
        print("{} {}".format(que[0][0], now))
        que.pop(0)