# queue.rb
s=STDIN.gets.split
n=s[0].to_i
q=s[1].to_i
queue=Array.new(n)
name =Array.new(n)
time =Array.new(n)

0.upto(n-1) {|i|
  s=STDIN.gets.split
  queue[i]=i
  name[i]=s[0].to_s
  time[i]=s[1].to_i
}

qp=0
elapsed=0
while (n>0) do
  top=queue[qp]
  if time[top] <= 100 then
    elapsed += time[top]
    printf("%s %d\n",name[top],elapsed)
    n-=1
  else
    elapsed += 100
    time[top] -= 100
    queue << top
  end
  qp+=1
end