n, q = map(int, input().split())
array = [[s for s in input().split()] for i in range(n)]
total_time = 0
while len(array) != 0:
    a = array.pop(0)
    a_t = int(a[1])
    if a_t - q <= 0:
        total_time += a_t
        a[1] = total_time
        print(a[0], a[1])
    else:
        a[1] = a_t - q
        array.append(a)
        total_time += q n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q [s for s in input().split()] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [s for s in input().split()] array = [[s for s in input().split()] for i in range(n)] array [[s for s in input().split()] for i in range(n)] total_time = 0 total_time 0 while len(array) != 0:
    a = array.pop(0)
    a_t = int(a[1])
    if a_t - q <= 0:
        total_time += a_t
        a[1] = total_time
        print(a[0], a[1])
    else:
        a[1] = a_t - q
        array.append(a)
        total_time += q len(array) != 0 len(array) len array 0 a = array.pop(0) a array.pop(0) array.pop array pop 0 a_t = int(a[1]) a_t int(a[1]) int a[1] a 1 if a_t - q <= 0:
        total_time += a_t
        a[1] = total_time
        print(a[0], a[1])
    else:
        a[1] = a_t - q
        array.append(a)
        total_time += q a_t - q <= 0 a_t - q a_t q 0 total_time += a_t total_time a_t a[1] = total_time a[1] a 1 total_time print(a[0], a[1]) print a[0] a 0 a[1] a 1 a[1] = a_t - q a[1] a 1 a_t - q a_t q array.append(a) array.append array append a total_time += q total_time q n, q = map(int, input().split()) map(int, input().split()) n a_t = int(a[1]) int(a[1]) a_t total_time += q q total_time total_time = 0 0 total_time array = [[s for s in input().split()] for i in range(n)] [[s for s in input().split()] for i in range(n)] array total_time += a_t a_t total_time q = map(int, input().split()) map(int, input().split()) q a = array.pop(0) array.pop(0) a
n, q = map(int, input().split())
array = [[s for s in input().split()] for i in range(n)]
total_time = 0
while len(array) != 0:
    a = array.pop(0)
    a_t = int(a[1])
    if a_t - q <= 0:
        total_time += a_t
        a[1] = total_time
        print(a[0], a[1])
    else:
        a[1] = a_t - q
        array.append(a)
        total_time += q