n, q = map(int, input().split(' '))
p = []
time = 0
counter = 0
for i in range(n):
    tmp_n, tmp_p = input().split(' ')
    tmp_p = int(tmp_p)
    p.append((tmp_n, tmp_p))

while len(p) > 0:
    task = p.pop(0)
    tmp_p = task[1] - q
    if( tmp_p > 0):
        time += q
        p.append((task[0], tmp_p))
    elif( tmp_p <= 0):
        time += task[1]
        print('{} {}'.format(task[0], time)) n, q = map(int, input().split(' ')) n map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' q p = [] p [] time = 0 time 0 counter = 0 counter 0 for i in range(n):
    tmp_n, tmp_p = input().split(' ')
    tmp_p = int(tmp_p)
    p.append((tmp_n, tmp_p)) i range(n) range n tmp_n, tmp_p = input().split(' ') tmp_n input().split(' ') ().split () input split ' ' tmp_p tmp_p = int(tmp_p) tmp_p int(tmp_p) int tmp_p p.append((tmp_n, tmp_p)) p.append p append (tmp_n, tmp_p) tmp_n tmp_p while len(p) > 0:
    task = p.pop(0)
    tmp_p = task[1] - q
    if( tmp_p > 0):
        time += q
        p.append((task[0], tmp_p))
    elif( tmp_p <= 0):
        time += task[1]
        print('{} {}'.format(task[0], time)) len(p) > 0 len(p) len p 0 task = p.pop(0) task p.pop(0) p.pop p pop 0 tmp_p = task[1] - q tmp_p task[1] - q task[1] task 1 q if( tmp_p > 0):
        time += q
        p.append((task[0], tmp_p))
    elif( tmp_p <= 0):
        time += task[1]
        print('{} {}'.format(task[0], time)) tmp_p > 0 tmp_p 0 time += q time q p.append((task[0], tmp_p)) p.append p append (task[0], tmp_p) task[0] task 0 tmp_p elif( tmp_p <= 0):
        time += task[1]
        print('{} {}'.format(task[0], time)) tmp_p <= 0 tmp_p 0 time += task[1] time task[1] task 1 print('{} {}'.format(task[0], time)) print '{} {}'.format(task[0], time) '{} {}'.format '{} {}' format task[0] task 0 time tmp_p = int(tmp_p) int(tmp_p) tmp_p tmp_p = input().split(' ') input().split(' ') tmp_p time += task[1] task[1] time p = [] [] p q = map(int, input().split(' ')) map(int, input().split(' ')) q time = 0 0 time tmp_n, tmp_p = input().split(' ') input().split(' ') tmp_n counter = 0 0 counter n, q = map(int, input().split(' ')) map(int, input().split(' ')) n task = p.pop(0) p.pop(0) task tmp_p = task[1] - q task[1] - q tmp_p time += q q time
n, q = map(int, input().split(' '))
p = []
time = 0
counter = 0
for i in range(n):
    tmp_n, tmp_p = input().split(' ')
    tmp_p = int(tmp_p)
    p.append((tmp_n, tmp_p))

while len(p) > 0:
    task = p.pop(0)
    tmp_p = task[1] - q
    if( tmp_p > 0):
        time += q
        p.append((task[0], tmp_p))
    elif( tmp_p <= 0):
        time += task[1]
        print('{} {}'.format(task[0], time))
