from Queue import Queue
n, q = map(int, raw_input().split())
P = []
for i in xrange(n):
    x = raw_input().split()
    P.append((x[0], int(x[1])))

Q = Queue()
for x in P:
    Q.put(x)
total = 0
while not Q.empty():
    x = Q.get()
    if x[1] <= q:
        total += x[1]
        print x[0], total
    else:
        total += q
        Q.put((x[0], x[1]-q)) from Queue import Queue n, q = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split q P = [] P [] for i in xrange(n):
    x = raw_input().split()
    P.append((x[0], int(x[1]))) i xrange(n) xrange n x = raw_input().split() x raw_input().split() ().split () raw_input split P.append((x[0], int(x[1]))) P.append P append (x[0], int(x[1])) x[0] x 0 int(x[1]) int x[1] x 1 Q = Queue() Q Queue() Queue for x in P:
    Q.put(x) x P Q.put(x) Q.put Q put x total = 0 total 0 while not Q.empty():
    x = Q.get()
    if x[1] <= q:
        total += x[1]
        print x[0], total
    else:
        total += q
        Q.put((x[0], x[1]-q)) not Q.empty() Q.empty() Q.empty Q empty x = Q.get() x Q.get() Q.get Q get if x[1] <= q:
        total += x[1]
        print x[0], total
    else:
        total += q
        Q.put((x[0], x[1]-q)) x[1] <= q x[1] x 1 q total += x[1] total x[1] x 1 print x[0] x 0 total total += q total q Q.put((x[0], x[1]-q)) Q.put Q put (x[0], x[1]-q) x[0] x 0 x[1]-q x[1] x 1 q total = 0 0 total x = Q.get() Q.get() x total += x[1] x[1] total Q = Queue() Queue() Q total += q q total P = [] [] P n, q = map(int, raw_input().split()) map(int, raw_input().split()) n q = map(int, raw_input().split()) map(int, raw_input().split()) q x = raw_input().split() raw_input().split() x
from Queue import Queue
n, q = map(int, raw_input().split())
P = []
for i in xrange(n):
    x = raw_input().split()
    P.append((x[0], int(x[1])))

Q = Queue()
for x in P:
    Q.put(x)
total = 0
while not Q.empty():
    x = Q.get()
    if x[1] <= q:
        total += x[1]
        print x[0], total
    else:
        total += q
        Q.put((x[0], x[1]-q))