import collections
n, q = map(int, input().split())
P = collections.deque()
for _ in range(n):
    name, time = input().split()
    P.append([name, int(time)])

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

total_time = 0
while P:
    name, time = P.popleft()
    if time <= q:
        total_time += time
        print(name, total_time)
    else:
        time -= q
        total_time += q
        P.append([name, time])