from collections import deque 
d = deque()
n, q = map(int, input().split())
for i in range(n):
    d.append(input().split())
now = 0
while d:
    name, time = d.popleft()
    time = int(time)
    if time <= q:
        now += time
        print(name, now)
    else:
        time -= q
        d.append([name, time])
        now += q from collections import deque d = deque() d deque() deque n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q for i in range(n):
    d.append(input().split()) i range(n) range n d.append(input().split()) d.append d append input().split() ().split () input split now = 0 now 0 while d:
    name, time = d.popleft()
    time = int(time)
    if time <= q:
        now += time
        print(name, now)
    else:
        time -= q
        d.append([name, time])
        now += q d name, time = d.popleft() name d.popleft() d.popleft d popleft time time = int(time) time int(time) int time if time <= q:
        now += time
        print(name, now)
    else:
        time -= q
        d.append([name, time])
        now += q time <= q time q now += time now time print(name, now) print name now time -= q time q d.append([name, time]) d.append d append [name, time] name time now += q now q now = 0 0 now name, time = d.popleft() d.popleft() name time = int(time) int(time) time n, q = map(int, input().split()) map(int, input().split()) n q = map(int, input().split()) map(int, input().split()) q now += time time now now += q q now time = d.popleft() d.popleft() time d = deque() deque() d time -= q q time
from collections import deque 
d = deque()
n, q = map(int, input().split())
for i in range(n):
    d.append(input().split())
now = 0
while d:
    name, time = d.popleft()
    time = int(time)
    if time <= q:
        now += time
        print(name, now)
    else:
        time -= q
        d.append([name, time])
        now += q