n, q = map(int, input().split())

s = list()
process = 0
t = list()
for i in range(n):
    name, time = map(str, input().split())
    s.append([name, int(time)])

flag = True
while s:
    diff = s[0][1] - q
    if diff <= 0:
        process += s[0][1]
        t.append([s[0][0], process])
        s.pop(0)
    else:
        process += q
        s.append([s[0][0], diff])
        s.pop(0)
for i in t:
    print(i[0], i[1]) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q s = list() s list() list process = 0 process 0 t = list() t list() list for i in range(n):
    name, time = map(str, input().split())
    s.append([name, int(time)]) i range(n) range n name, time = map(str, input().split()) name map(str, input().split()) map str input().split() ().split () input split time s.append([name, int(time)]) s.append s append [name, int(time)] name int(time) int time flag = True flag True while s:
    diff = s[0][1] - q
    if diff <= 0:
        process += s[0][1]
        t.append([s[0][0], process])
        s.pop(0)
    else:
        process += q
        s.append([s[0][0], diff])
        s.pop(0) s diff = s[0][1] - q diff s[0][1] - q s[0][1] [0] s 0 1 q if diff <= 0:
        process += s[0][1]
        t.append([s[0][0], process])
        s.pop(0)
    else:
        process += q
        s.append([s[0][0], diff])
        s.pop(0) diff <= 0 diff 0 process += s[0][1] process s[0][1] [0] s 0 1 t.append([s[0][0], process]) t.append t append [s[0][0], process] s[0][0] [0] s 0 0 process s.pop(0) s.pop s pop 0 process += q process q s.append([s[0][0], diff]) s.append s append [s[0][0], diff] s[0][0] [0] s 0 0 diff s.pop(0) s.pop s pop 0 for i in t:
    print(i[0], i[1]) i t print(i[0], i[1]) print i[0] i 0 i[1] i 1 s = list() list() s process += s[0][1] s[0][1] process n, q = map(int, input().split()) map(int, input().split()) n name, time = map(str, input().split()) map(str, input().split()) name process = 0 0 process time = map(str, input().split()) map(str, input().split()) time process += q q process q = map(int, input().split()) map(int, input().split()) q diff = s[0][1] - q s[0][1] - q diff flag = True True flag t = list() list() t
n, q = map(int, input().split())

s = list()
process = 0
t = list()
for i in range(n):
    name, time = map(str, input().split())
    s.append([name, int(time)])

flag = True
while s:
    diff = s[0][1] - q
    if diff <= 0:
        process += s[0][1]
        t.append([s[0][0], process])
        s.pop(0)
    else:
        process += q
        s.append([s[0][0], diff])
        s.pop(0)
for i in t:
    print(i[0], i[1])