from collections import deque
n,q=map(int,raw_input().split())
l=deque([raw_input().split()for _ in range(n)])
t=0
while len(l):
 a,b=l.popleft()
 b=int(b)
 if q<b: t+=q;l.append([a,b-q])
 else:   t+=b;print a,t from collections import deque n,q=map(int,raw_input().split()) n map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split q raw_input().split()for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) raw_input().split() ().split () raw_input split l=deque([raw_input().split()for _ in range(n)]) l deque([raw_input().split()for _ in range(n)]) deque [raw_input().split()for _ in range(n)] t=0 t 0 while len(l):
 a,b=l.popleft()
 b=int(b)
 if q<b: t+=q;l.append([a,b-q])
 else:   t+=b;print a,t len(l) len l a,b=l.popleft() a l.popleft() l.popleft l popleft b b=int(b) b int(b) int b if q<b: t+=q;l.append([a,b-q])
 else:   t+=b;print q<b q b a t b=int(b) int(b) b t=0 0 t l=deque([raw_input().split()for _ in range(n)]) deque([raw_input().split()for _ in range(n)]) l a,b=l.popleft() l.popleft() a q=map(int,raw_input().split()) map(int,raw_input().split()) q n,q=map(int,raw_input().split()) map(int,raw_input().split()) n b=l.popleft() l.popleft() b
from collections import deque
n,q=map(int,raw_input().split())
l=deque([raw_input().split()for _ in range(n)])
t=0
while len(l):
 a,b=l.popleft()
 b=int(b)
 if q<b: t+=q;l.append([a,b-q])
 else:   t+=b;print a,t