import sys
import collections
s=sys.stdin.readlines()
n,q=map(int,s[0].split())
d=collections.deque(e.split()for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 v=int(v)
 if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t) import sys sys import collections collections s=sys.stdin.readlines() s sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines n,q=map(int,s[0].split()) n map(int,s[0].split()) map int s[0].split() [0].split [0] s 0 split q d=collections.deque(e.split()for e in s[1:]) d collections.deque(e.split()for e in s[1:]) collections.deque collections deque e.split() e.split e split t=0 t 0 while d:
 k,v=d.popleft()
 v=int(v)
 if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t) d k,v=d.popleft() k d.popleft() d.popleft d popleft v v=int(v) v int(v) int v if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t) v>q v q v-=q v q t+=q t q d.append([k,v]) d.append d append [k,v] k v t+=v t v print(k,t) print k t v-=q q v v=int(v) int(v) v k,v=d.popleft() d.popleft() k s=sys.stdin.readlines() sys.stdin.readlines() s q=map(int,s[0].split()) map(int,s[0].split()) q t+=q q t n,q=map(int,s[0].split()) map(int,s[0].split()) n d=collections.deque(e.split()for e in s[1:]) collections.deque(e.split()for e in s[1:]) d v=d.popleft() d.popleft() v t+=v v t t=0 0 t
import sys
import collections
s=sys.stdin.readlines()
n,q=map(int,s[0].split())
d=collections.deque(e.split()for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 v=int(v)
 if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t)
