h, w = gets.split.map &:to_i
#tree = SegTree.new w
j = 0
count = 0
cannot = false
h.times do
  a, b = gets.split.map &:to_i
  if cannot
    p -1
  elsif j + 1 < a
    count += 1
    p count
  elsif b < w
    count += b - j + 1
    p count
    j = b
  else
    cannot = true
    p -1
  end
end