n, q = map(int, input().split())
l = [list(input().split()) for i in range(n)]
from collections import deque
que = deque([[l[i][0], int(l[i][1])] for i in range(n)])
a = []
time = 0
while que != deque([]):
    a = que.popleft()
    if a[1] <= q:
        time += a[1]
        print("{} {}".format(a[0], str(time)))
    else:
        time += q
        a[0], a[1] = a[0], a[1] - q
        que.append(a) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q list(input().split()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(input().split()) list input().split() ().split () input split l = [list(input().split()) for i in range(n)] l [list(input().split()) for i in range(n)] from collections import deque [l[i][0], int(l[i][1])] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [l[i][0], int(l[i][1])] l[i][0] [i] l i 0 int(l[i][1]) int l[i][1] [i] l i 1 que = deque([[l[i][0], int(l[i][1])] for i in range(n)]) que deque([[l[i][0], int(l[i][1])] for i in range(n)]) deque [[l[i][0], int(l[i][1])] for i in range(n)] a = [] a [] time = 0 time 0 while que != deque([]):
    a = que.popleft()
    if a[1] <= q:
        time += a[1]
        print("{} {}".format(a[0], str(time)))
    else:
        time += q
        a[0], a[1] = a[0], a[1] - q
        que.append(a) que != deque([]) que deque([]) deque [] a = que.popleft() a que.popleft() que.popleft que popleft if a[1] <= q:
        time += a[1]
        print("{} {}".format(a[0], str(time)))
    else:
        time += q
        a[0], a[1] = a[0], a[1] - q
        que.append(a) a[1] <= q a[1] a 1 q time += a[1] time a[1] a 1 print("{} {}".format(a[0], str(time))) print "{} {}".format(a[0], str(time)) "{} {}".format "{} {}" format a[0] a 0 str(time) str time time += q time q a[0], a[1] = a[0], a[1] - q a[0] a 0 a[0] a 0 a[1] a 1 a[1] - q a[1] a 1 q que.append(a) que.append que append a q = map(int, input().split()) map(int, input().split()) q n, q = map(int, input().split()) map(int, input().split()) n a = [] [] a time += q q time l = [list(input().split()) for i in range(n)] [list(input().split()) for i in range(n)] l que = deque([[l[i][0], int(l[i][1])] for i in range(n)]) deque([[l[i][0], int(l[i][1])] for i in range(n)]) que a = que.popleft() que.popleft() a time = 0 0 time time += a[1] a[1] time
n, q = map(int, input().split())
l = [list(input().split()) for i in range(n)]
from collections import deque
que = deque([[l[i][0], int(l[i][1])] for i in range(n)])
a = []
time = 0
while que != deque([]):
    a = que.popleft()
    if a[1] <= q:
        time += a[1]
        print("{} {}".format(a[0], str(time)))
    else:
        time += q
        a[0], a[1] = a[0], a[1] - q
        que.append(a)