n, q = [int(i) for i in input().split(" ")]

current = 0
queue = []
for _ in range(n):
    name, t = input().split(" ")
    t = int(t)
    if t <= q:
        current += t
        print("{} {}".format(name, current))
    else:
        current += q
        queue.append((name, int(t - q)))

while len(queue) > 0:
    nqueue = []
    for name, t in queue:
        if t <= q:
            t = int(t)
            current += t
            print("{} {}".format(name, current))
        else:
            current += q
            nqueue.append((name, int(t - q)))
    queue = nqueue int(i) for i in input().split(" ") for i in input().split(" ") i input().split(" ") ().split () input split " " for i in input().split(" ") int(i) int i n, q = [int(i) for i in input().split(" ")] n [int(i) for i in input().split(" ")] q current = 0 current 0 queue = [] queue [] for _ in range(n):
    name, t = input().split(" ")
    t = int(t)
    if t <= q:
        current += t
        print("{} {}".format(name, current))
    else:
        current += q
        queue.append((name, int(t - q))) _ range(n) range n name, t = input().split(" ") name input().split(" ") ().split () input split " " t t = int(t) t int(t) int t if t <= q:
        current += t
        print("{} {}".format(name, current))
    else:
        current += q
        queue.append((name, int(t - q))) t <= q t q current += t current t print("{} {}".format(name, current)) print "{} {}".format(name, current) "{} {}".format "{} {}" format name current current += q current q queue.append((name, int(t - q))) queue.append queue append (name, int(t - q)) name int(t - q) int t - q t q while len(queue) > 0:
    nqueue = []
    for name, t in queue:
        if t <= q:
            t = int(t)
            current += t
            print("{} {}".format(name, current))
        else:
            current += q
            nqueue.append((name, int(t - q)))
    queue = nqueue len(queue) > 0 len(queue) len queue 0 nqueue = [] nqueue [] for name, t in queue:
        if t <= q:
            t = int(t)
            current += t
            print("{} {}".format(name, current))
        else:
            current += q
            nqueue.append((name, int(t - q)))
     name t queue if t <= q:
            t = int(t)
            current += t
            print("{} {}".format(name, current))
        else:
            current += q
            nqueue.append((name, int(t - q)))
     t <= q t q t = int(t) t int(t) int t current += t current t print("{} {}".format(name, current)) print "{} {}".format(name, current) "{} {}".format "{} {}" format name current current += q current q nqueue.append((name, int(t - q))) nqueue.append nqueue append (name, int(t - q)) name int(t - q) int t - q t q queue = nqueue queue nqueue q = [int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] q queue = nqueue nqueue queue t = input().split(" ") input().split(" ") t current += q q current n, q = [int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] n t = int(t) int(t) t name, t = input().split(" ") input().split(" ") name current += t t current current += q q current queue = [] [] queue current = 0 0 current nqueue = [] [] nqueue current += t t current t = int(t) int(t) t
n, q = [int(i) for i in input().split(" ")]

current = 0
queue = []
for _ in range(n):
    name, t = input().split(" ")
    t = int(t)
    if t <= q:
        current += t
        print("{} {}".format(name, current))
    else:
        current += q
        queue.append((name, int(t - q)))

while len(queue) > 0:
    nqueue = []
    for name, t in queue:
        if t <= q:
            t = int(t)
            current += t
            print("{} {}".format(name, current))
        else:
            current += q
            nqueue.append((name, int(t - q)))
    queue = nqueue