n, q = map(int, raw_input().split())
A = [[0, 0] for i in range(n)]

for i in range(n):
    temp = raw_input().split()
    A[i][0] = temp[0]
    A[i][1] = int(temp[1])

time = 0
while A != []:
    if A[0][1] - q > 0:
        A[0][1] = A[0][1] - q
        time = time + q
        A.append(A.pop(0))
    else:
        print A[0][0],
        print time + A[0][1]
        time = time + A[0][1]
        A.pop(0) n, q = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split q [0, 0] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [0, 0] 0 0 A = [[0, 0] for i in range(n)] A [[0, 0] for i in range(n)] for i in range(n):
    temp = raw_input().split()
    A[i][0] = temp[0]
    A[i][1] = int(temp[1]) i range(n) range n temp = raw_input().split() temp raw_input().split() ().split () raw_input split A[i][0] = temp[0] A[i][0] [i] A i 0 temp[0] temp 0 A[i][1] = int(temp[1]) A[i][1] [i] A i 1 int(temp[1]) int temp[1] temp 1 time = 0 time 0 while A != []:
    if A[0][1] - q > 0:
        A[0][1] = A[0][1] - q
        time = time + q
        A.append(A.pop(0))
    else:
        print A[0][0],
        print time + A[0][1]
        time = time + A[0][1]
        A.pop(0) A != [] A [] if A[0][1] - q > 0:
        A[0][1] = A[0][1] - q
        time = time + q
        A.append(A.pop(0))
    else:
        print A[0][0],
        print time + A[0][1]
        time = time + A[0][1]
        A.pop(0) A[0][1] - q > 0 A[0][1] - q A[0][1] [0] A 0 1 q 0 A[0][1] = A[0][1] - q A[0][1] [0] A 0 1 A[0][1] - q A[0][1] [0] A 0 1 q time = time + q time time + q time q A.append(A.pop(0)) A.append A append A.pop(0) A.pop A pop 0 print A[0][0] [0] A 0 0 print time + A[0][1] time A[0][1] [0] A 0 1 time = time + A[0][1] time time + A[0][1] time A[0][1] [0] A 0 1 A.pop(0) A.pop A pop 0 temp = raw_input().split() raw_input().split() temp time = time + A[0][1] time + A[0][1] time q = map(int, raw_input().split()) map(int, raw_input().split()) q A = [[0, 0] for i in range(n)] [[0, 0] for i in range(n)] A n, q = map(int, raw_input().split()) map(int, raw_input().split()) n time = 0 0 time time = time + q time + q time
n, q = map(int, raw_input().split())
A = [[0, 0] for i in range(n)]

for i in range(n):
    temp = raw_input().split()
    A[i][0] = temp[0]
    A[i][1] = int(temp[1])

time = 0
while A != []:
    if A[0][1] - q > 0:
        A[0][1] = A[0][1] - q
        time = time + q
        A.append(A.pop(0))
    else:
        print A[0][0],
        print time + A[0][1]
        time = time + A[0][1]
        A.pop(0)