from collections import deque

n, q = [int(_) for _ in input().split()]
processes = deque([tuple(input().split()) for i in range(n)])

time = 0
while processes:
    process = processes.popleft()

    if int(process[1]) <= q:
        time += int(process[1])
        print(process[0], time)

    else:
        time += q
        processes.append((process[0], int(process[1]) - q))
 from collections import deque int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ n, q = [int(_) for _ in input().split()] n [int(_) for _ in input().split()] q tuple(input().split()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) tuple(input().split()) tuple input().split() ().split () input split processes = deque([tuple(input().split()) for i in range(n)]) processes deque([tuple(input().split()) for i in range(n)]) deque [tuple(input().split()) for i in range(n)] time = 0 time 0 while processes:
    process = processes.popleft()

    if int(process[1]) <= q:
        time += int(process[1])
        print(process[0], time)

    else:
        time += q
        processes.append((process[0], int(process[1]) - q)) processes process = processes.popleft() process processes.popleft() processes.popleft processes popleft if int(process[1]) <= q:
        time += int(process[1])
        print(process[0], time)

    else:
        time += q
        processes.append((process[0], int(process[1]) - q)) int(process[1]) <= q int(process[1]) int process[1] process 1 q time += int(process[1]) time int(process[1]) int process[1] process 1 print(process[0], time) print process[0] process 0 time time += q time q processes.append((process[0], int(process[1]) - q)) processes.append processes append (process[0], int(process[1]) - q) process[0] process 0 int(process[1]) - q int(process[1]) int process[1] process 1 q processes = deque([tuple(input().split()) for i in range(n)]) deque([tuple(input().split()) for i in range(n)]) processes time = 0 0 time time += int(process[1]) int(process[1]) time time += q q time process = processes.popleft() processes.popleft() process n, q = [int(_) for _ in input().split()] [int(_) for _ in input().split()] n q = [int(_) for _ in input().split()] [int(_) for _ in input().split()] q
from collections import deque

n, q = [int(_) for _ in input().split()]
processes = deque([tuple(input().split()) for i in range(n)])

time = 0
while processes:
    process = processes.popleft()

    if int(process[1]) <= q:
        time += int(process[1])
        print(process[0], time)

    else:
        time += q
        processes.append((process[0], int(process[1]) - q))

