n, q = map(int, input().split(' '))
L = []
i = 0
while i < n:
    name, time = map(str, input().split(' '))
    L.append([name, int(time)])
    i += 1
t = 0
fin = []
while len(L) != 0:
    if L[0][1] > q:
        t += q
        name = L[0][0]
        time = L[0][1] - q
        L.append([name, time])
        L.pop(0)
    else:
        t += L[0][1]
        name = L[0][0]
        time = t
        fin.append([name, time])
        L.pop(0)
ans = ''
for f in fin:
    ans += f[0] + ' ' + str(f[1]) + '\n'
print(ans[:-1]) n, q = map(int, input().split(' ')) n map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' q L = [] L [] i = 0 i 0 while i < n:
    name, time = map(str, input().split(' '))
    L.append([name, int(time)])
    i += 1 i < n i n name, time = map(str, input().split(' ')) name map(str, input().split(' ')) map str input().split(' ') ().split () input split ' ' time L.append([name, int(time)]) L.append L append [name, int(time)] name int(time) int time i += 1 i 1 t = 0 t 0 fin = [] fin [] while len(L) != 0:
    if L[0][1] > q:
        t += q
        name = L[0][0]
        time = L[0][1] - q
        L.append([name, time])
        L.pop(0)
    else:
        t += L[0][1]
        name = L[0][0]
        time = t
        fin.append([name, time])
        L.pop(0) len(L) != 0 len(L) len L 0 if L[0][1] > q:
        t += q
        name = L[0][0]
        time = L[0][1] - q
        L.append([name, time])
        L.pop(0)
    else:
        t += L[0][1]
        name = L[0][0]
        time = t
        fin.append([name, time])
        L.pop(0) L[0][1] > q L[0][1] [0] L 0 1 q t += q t q name = L[0][0] name L[0][0] [0] L 0 0 time = L[0][1] - q time L[0][1] - q L[0][1] [0] L 0 1 q L.append([name, time]) L.append L append [name, time] name time L.pop(0) L.pop L pop 0 t += L[0][1] t L[0][1] [0] L 0 1 name = L[0][0] name L[0][0] [0] L 0 0 time = t time t fin.append([name, time]) fin.append fin append [name, time] name time L.pop(0) L.pop L pop 0 ans = '' ans '' for f in fin:
    ans += f[0] + ' ' + str(f[1]) + '\n' f fin ans += f[0] + ' ' + str(f[1]) + '\n' ans f[0] + ' ' + str(f[1]) + '\n' f[0] + ' ' + str(f[1]) f[0] + ' ' f[0] f 0 ' ' str(f[1]) str f[1] f 1 '\n' print(ans[:-1]) print ans[:-1] ans :-1 -1 time = t t time name, time = map(str, input().split(' ')) map(str, input().split(' ')) name name = L[0][0] L[0][0] name t += q q t i += 1 1 i t += L[0][1] L[0][1] t ans += f[0] + ' ' + str(f[1]) + '\n' f[0] + ' ' + str(f[1]) + '\n' ans ans = '' '' ans i = 0 0 i t = 0 0 t q = map(int, input().split(' ')) map(int, input().split(' ')) q time = map(str, input().split(' ')) map(str, input().split(' ')) time fin = [] [] fin name = L[0][0] L[0][0] name time = L[0][1] - q L[0][1] - q time L = [] [] L n, q = map(int, input().split(' ')) map(int, input().split(' ')) n
n, q = map(int, input().split(' '))
L = []
i = 0
while i < n:
    name, time = map(str, input().split(' '))
    L.append([name, int(time)])
    i += 1
t = 0
fin = []
while len(L) != 0:
    if L[0][1] > q:
        t += q
        name = L[0][0]
        time = L[0][1] - q
        L.append([name, time])
        L.pop(0)
    else:
        t += L[0][1]
        name = L[0][0]
        time = t
        fin.append([name, time])
        L.pop(0)
ans = ''
for f in fin:
    ans += f[0] + ' ' + str(f[1]) + '\n'
print(ans[:-1])
