n, q = [int(e) for e in input().split()]
A = []
res = []
for i in range(n):
    l = input().split()
    A.append((l[0], int(l[1])))

idx = 0
tot_t = 0
while A:
    dif = A[0][1] - q
    if dif <= 0:
        tot_t += A[0][1]
        res.append((A[0][0], tot_t))
        A.pop(0)
    else:
        tmp = (A[0][0], dif)
        A.pop(0)
        A.append(tmp)
        tot_t += q

for e in res:
    print(e[0], e[1])
 int(e) for e in input().split() for e in input().split() e input().split() ().split () input split for e in input().split() int(e) int e n, q = [int(e) for e in input().split()] n [int(e) for e in input().split()] q A = [] A [] res = [] res [] for i in range(n):
    l = input().split()
    A.append((l[0], int(l[1]))) i range(n) range n l = input().split() l input().split() ().split () input split A.append((l[0], int(l[1]))) A.append A append (l[0], int(l[1])) l[0] l 0 int(l[1]) int l[1] l 1 idx = 0 idx 0 tot_t = 0 tot_t 0 while A:
    dif = A[0][1] - q
    if dif <= 0:
        tot_t += A[0][1]
        res.append((A[0][0], tot_t))
        A.pop(0)
    else:
        tmp = (A[0][0], dif)
        A.pop(0)
        A.append(tmp)
        tot_t += q A dif = A[0][1] - q dif A[0][1] - q A[0][1] [0] A 0 1 q if dif <= 0:
        tot_t += A[0][1]
        res.append((A[0][0], tot_t))
        A.pop(0)
    else:
        tmp = (A[0][0], dif)
        A.pop(0)
        A.append(tmp)
        tot_t += q dif <= 0 dif 0 tot_t += A[0][1] tot_t A[0][1] [0] A 0 1 res.append((A[0][0], tot_t)) res.append res append (A[0][0], tot_t) A[0][0] [0] A 0 0 tot_t A.pop(0) A.pop A pop 0 tmp = (A[0][0], dif) tmp (A[0][0], dif) A[0][0] [0] A 0 0 dif A.pop(0) A.pop A pop 0 A.append(tmp) A.append A append tmp tot_t += q tot_t q for e in res:
    print(e[0], e[1]) e res print(e[0], e[1]) print e[0] e 0 e[1] e 1 A = [] [] A n, q = [int(e) for e in input().split()] [int(e) for e in input().split()] n idx = 0 0 idx q = [int(e) for e in input().split()] [int(e) for e in input().split()] q tot_t += A[0][1] A[0][1] tot_t tmp = (A[0][0], dif) (A[0][0], dif) tmp dif = A[0][1] - q A[0][1] - q dif res = [] [] res l = input().split() input().split() l tot_t = 0 0 tot_t tot_t += q q tot_t
n, q = [int(e) for e in input().split()]
A = []
res = []
for i in range(n):
    l = input().split()
    A.append((l[0], int(l[1])))

idx = 0
tot_t = 0
while A:
    dif = A[0][1] - q
    if dif <= 0:
        tot_t += A[0][1]
        res.append((A[0][0], tot_t))
        A.pop(0)
    else:
        tmp = (A[0][0], dif)
        A.pop(0)
        A.append(tmp)
        tot_t += q

for e in res:
    print(e[0], e[1])

