n, q = map(int, input().split())
p = [input().split() for _ in range(n)]
t = i = 0
while n:
    i = i % n
    if int(p[i][1]) <= q:
        t += int(p[i][1])
        print(p[i][0], t)
        del p[i]
        n -= 1
    else:
        p[i][1] = int(p[i][1]) - q
        t += q
        i += 1 n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q input().split() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) input().split() ().split () input split p = [input().split() for _ in range(n)] p [input().split() for _ in range(n)] t = i = 0 t 0 = i = 0 i 0 while n:
    i = i % n
    if int(p[i][1]) <= q:
        t += int(p[i][1])
        print(p[i][0], t)
        del p[i]
        n -= 1
    else:
        p[i][1] = int(p[i][1]) - q
        t += q
        i += 1 n i = i % n i i % n i n if int(p[i][1]) <= q:
        t += int(p[i][1])
        print(p[i][0], t)
        del p[i]
        n -= 1
    else:
        p[i][1] = int(p[i][1]) - q
        t += q
        i += 1 int(p[i][1]) <= q int(p[i][1]) int p[i][1] [i] p i 1 q t += int(p[i][1]) t int(p[i][1]) int p[i][1] [i] p i 1 print(p[i][0], t) print p[i][0] [i] p i 0 t del p[i] p[i] p i n -= 1 n 1 p[i][1] = int(p[i][1]) - q p[i][1] [i] p i 1 int(p[i][1]) - q int(p[i][1]) int p[i][1] [i] p i 1 q t += q t q i += 1 i 1 q = map(int, input().split()) map(int, input().split()) q i = i % n i % n i t += int(p[i][1]) int(p[i][1]) t n -= 1 1 n i += 1 1 i t = i = 0 0 t i = 0 0 i t += q q t n, q = map(int, input().split()) map(int, input().split()) n p = [input().split() for _ in range(n)] [input().split() for _ in range(n)] p
n, q = map(int, input().split())
p = [input().split() for _ in range(n)]
t = i = 0
while n:
    i = i % n
    if int(p[i][1]) <= q:
        t += int(p[i][1])
        print(p[i][0], t)
        del p[i]
        n -= 1
    else:
        p[i][1] = int(p[i][1]) - q
        t += q
        i += 1