time = 0
n, q = map(int, input().split())
qname = list(range(n))
qtime = list(range(n))
ename = []
etime = []
for i in range(n):
    inp = input().split()
    qname[i], qtime[i] = inp[0], int(inp[1])
while len(qtime) > 0:
    if qtime[0] <= q:
        time += qtime.pop(0)
        ename.append(qname.pop(0))
        etime.append(time)
    else:
        time += q
        qname.append(qname.pop(0))
        qtime.append(qtime.pop(0)-q)
for (a, b) in zip(ename, etime):
    print(a, b) time = 0 time 0 n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q qname = list(range(n)) qname list(range(n)) list range(n) range n qtime = list(range(n)) qtime list(range(n)) list range(n) range n ename = [] ename [] etime = [] etime [] for i in range(n):
    inp = input().split()
    qname[i], qtime[i] = inp[0], int(inp[1]) i range(n) range n inp = input().split() inp input().split() ().split () input split qname[i], qtime[i] = inp[0], int(inp[1]) qname[i] qname i inp[0] inp 0 qtime[i] qtime i int(inp[1]) int inp[1] inp 1 while len(qtime) > 0:
    if qtime[0] <= q:
        time += qtime.pop(0)
        ename.append(qname.pop(0))
        etime.append(time)
    else:
        time += q
        qname.append(qname.pop(0))
        qtime.append(qtime.pop(0)-q) len(qtime) > 0 len(qtime) len qtime 0 if qtime[0] <= q:
        time += qtime.pop(0)
        ename.append(qname.pop(0))
        etime.append(time)
    else:
        time += q
        qname.append(qname.pop(0))
        qtime.append(qtime.pop(0)-q) qtime[0] <= q qtime[0] qtime 0 q time += qtime.pop(0) time qtime.pop(0) qtime.pop qtime pop 0 ename.append(qname.pop(0)) ename.append ename append qname.pop(0) qname.pop qname pop 0 etime.append(time) etime.append etime append time time += q time q qname.append(qname.pop(0)) qname.append qname append qname.pop(0) qname.pop qname pop 0 qtime.append(qtime.pop(0)-q) qtime.append qtime append qtime.pop(0)-q qtime.pop(0) qtime.pop qtime pop 0 q for (a, b) in zip(ename, etime):
    print(a, b) (a, b) a b zip(ename, etime) zip ename etime print(a, b) print a b ename = [] [] ename qtime = list(range(n)) list(range(n)) qtime etime = [] [] etime inp = input().split() input().split() inp n, q = map(int, input().split()) map(int, input().split()) n qname = list(range(n)) list(range(n)) qname q = map(int, input().split()) map(int, input().split()) q time = 0 0 time time += q q time time += qtime.pop(0) qtime.pop(0) time
time = 0
n, q = map(int, input().split())
qname = list(range(n))
qtime = list(range(n))
ename = []
etime = []
for i in range(n):
    inp = input().split()
    qname[i], qtime[i] = inp[0], int(inp[1])
while len(qtime) > 0:
    if qtime[0] <= q:
        time += qtime.pop(0)
        ename.append(qname.pop(0))
        etime.append(time)
    else:
        time += q
        qname.append(qname.pop(0))
        qtime.append(qtime.pop(0)-q)
for (a, b) in zip(ename, etime):
    print(a, b)