n,t = gets.split.map(&:to_i)
data = []
n.times do
  tmp = gets.split
  data << [tmp[0],tmp[1].to_i]
end

result = []

now_t = 0
while !data.empty?
  if data[0][1] > t
    now_t += t
    data[0][1] -= t
    incomplete_elem = data.shift
    data << incomplete_elem 
  else
    now_t += data[0][1]
    complete_elem = data.shift
    result << complete_elem[0]+" "+now_t.to_s
  end
end
puts result.join("\n")