n, p = map(int, input().split())
ps = []
for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1])
t = 0
while len(ps) > 0:
    if ps[0][1] > p:
        ps.append([ps[0][0], ps[0][1] - p])
        t += p
        ps.pop(0)
    else:
        t += ps[0][1]
        print("{0} {1}".format(ps[0][0], t))
        ps.pop(0) n, p = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split p ps = [] ps [] for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1]) i range(n) range n ps.append(input().split()) ps.append ps append input().split() ().split () input split ps[i][1] = int(ps[i][1]) ps[i][1] [i] ps i 1 int(ps[i][1]) int ps[i][1] [i] ps i 1 t = 0 t 0 while len(ps) > 0:
    if ps[0][1] > p:
        ps.append([ps[0][0], ps[0][1] - p])
        t += p
        ps.pop(0)
    else:
        t += ps[0][1]
        print("{0} {1}".format(ps[0][0], t))
        ps.pop(0) len(ps) > 0 len(ps) len ps 0 if ps[0][1] > p:
        ps.append([ps[0][0], ps[0][1] - p])
        t += p
        ps.pop(0)
    else:
        t += ps[0][1]
        print("{0} {1}".format(ps[0][0], t))
        ps.pop(0) ps[0][1] > p ps[0][1] [0] ps 0 1 p ps.append([ps[0][0], ps[0][1] - p]) ps.append ps append [ps[0][0], ps[0][1] - p] ps[0][0] [0] ps 0 0 ps[0][1] - p ps[0][1] [0] ps 0 1 p t += p t p ps.pop(0) ps.pop ps pop 0 t += ps[0][1] t ps[0][1] [0] ps 0 1 print("{0} {1}".format(ps[0][0], t)) print "{0} {1}".format(ps[0][0], t) "{0} {1}".format "{0} {1}" format ps[0][0] [0] ps 0 0 t ps.pop(0) ps.pop ps pop 0 t += ps[0][1] ps[0][1] t p = map(int, input().split()) map(int, input().split()) p t = 0 0 t n, p = map(int, input().split()) map(int, input().split()) n ps = [] [] ps t += p p t
n, p = map(int, input().split())
ps = []
for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1])
t = 0
while len(ps) > 0:
    if ps[0][1] > p:
        ps.append([ps[0][0], ps[0][1] - p])
        t += p
        ps.pop(0)
    else:
        t += ps[0][1]
        print("{0} {1}".format(ps[0][0], t))
        ps.pop(0)
