# coding: UTF-8
from collections import deque
queue = deque()
ftime = deque()
n,quantum = map(int,input().split())
for i in range(n):
  name,time = input().split()
  time = int(time)
  queue.append((name,time))

t = 0
while queue:
 name,time = queue.popleft()
 if time <= quantum:
   t += time
   ftime.append(name + " " + str(t))
 else:
   t += quantum
   queue.append((name,time-quantum))

while ftime:
  print(ftime.popleft())
   
  from collections import deque queue = deque() queue deque() deque ftime = deque() ftime deque() deque n,quantum = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split quantum for i in range(n):
  name,time = input().split()
  time = int(time)
  queue.append((name,time)) i range(n) range n name,time = input().split() name input().split() ().split () input split time time = int(time) time int(time) int time queue.append((name,time)) queue.append queue append (name,time) name time t = 0 t 0 while queue:
 name,time = queue.popleft()
 if time <= quantum:
   t += time
   ftime.append(name + " " + str(t))
 else:
   t += quantum
   queue.append((name,time-quantum)) queue name,time = queue.popleft() name queue.popleft() queue.popleft queue popleft time if time <= quantum:
   t += time
   ftime.append(name + " " + str(t))
 else:
   t += quantum
   queue.append((name,time-quantum)) time <= quantum time quantum t += time t time ftime.append(name + " " + str(t)) ftime.append ftime append name + " " + str(t) name + " " name " " str(t) str t t += quantum t quantum queue.append((name,time-quantum)) queue.append queue append (name,time-quantum) name time-quantum time quantum while ftime:
  print(ftime.popleft())
   
  ftime print(ftime.popleft()) print ftime.popleft() ftime.popleft ftime popleft quantum = map(int,input().split()) map(int,input().split()) quantum t += time time t time = input().split() input().split() time time = int(time) int(time) time t = 0 0 t name,time = queue.popleft() queue.popleft() name time = queue.popleft() queue.popleft() time ftime = deque() deque() ftime t += quantum quantum t queue = deque() deque() queue n,quantum = map(int,input().split()) map(int,input().split()) n name,time = input().split() input().split() name
# coding: UTF-8
from collections import deque
queue = deque()
ftime = deque()
n,quantum = map(int,input().split())
for i in range(n):
  name,time = input().split()
  time = int(time)
  queue.append((name,time))

t = 0
while queue:
 name,time = queue.popleft()
 if time <= quantum:
   t += time
   ftime.append(name + " " + str(t))
 else:
   t += quantum
   queue.append((name,time-quantum))

while ftime:
  print(ftime.popleft())
   
 
