import sys
n, q = map(int, input().split())
queue = [[label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines())] 
i = 0
time = 0
while len(queue) > 0:
    i = i % len(queue)
    time += q
    queue[i][1] -= q
    if queue[i][1] <= 0:
        time += queue[i][1]
        print("{} {}".format(queue[i][0], time))
        queue.pop(i)
        i -= 1
    i += 1 import sys sys n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q [label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines()) for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines()) label num map(lambda line: line.strip().split(), sys.stdin.readlines()) map lambda line: line.strip().split() line.strip().split() line.strip().split line.strip() line.strip line strip split line sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines()) [label, int(num)] label int(num) int num queue = [[label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines())] queue [[label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines())] i = 0 i 0 time = 0 time 0 while len(queue) > 0:
    i = i % len(queue)
    time += q
    queue[i][1] -= q
    if queue[i][1] <= 0:
        time += queue[i][1]
        print("{} {}".format(queue[i][0], time))
        queue.pop(i)
        i -= 1
    i += 1 len(queue) > 0 len(queue) len queue 0 i = i % len(queue) i i % len(queue) i len(queue) len queue time += q time q queue[i][1] -= q queue[i][1] [i] queue i 1 q if queue[i][1] <= 0:
        time += queue[i][1]
        print("{} {}".format(queue[i][0], time))
        queue.pop(i)
        i -= 1
     queue[i][1] <= 0 queue[i][1] [i] queue i 1 0 time += queue[i][1] time queue[i][1] [i] queue i 1 print("{} {}".format(queue[i][0], time)) print "{} {}".format(queue[i][0], time) "{} {}".format "{} {}" format queue[i][0] [i] queue i 0 time queue.pop(i) queue.pop queue pop i i -= 1 i 1 i += 1 i 1 time += q q time queue = [[label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines())] [[label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines())] queue q = map(int, input().split()) map(int, input().split()) q i += 1 1 i n, q = map(int, input().split()) map(int, input().split()) n i = 0 0 i i = i % len(queue) i % len(queue) i time += queue[i][1] queue[i][1] time time = 0 0 time i -= 1 1 i
import sys
n, q = map(int, input().split())
queue = [[label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines())] 
i = 0
time = 0
while len(queue) > 0:
    i = i % len(queue)
    time += q
    queue[i][1] -= q
    if queue[i][1] <= 0:
        time += queue[i][1]
        print("{} {}".format(queue[i][0], time))
        queue.pop(i)
        i -= 1
    i += 1
