(H,W),*A=$<.map{_1.split.map &:to_i}
N=W+1
$segtree = [1e9]*N + [*0...N]

def chmin l, r, val
  l += N
  r += N
  while l < r
    # p [l, r, val]
    if l & 1 > 0
      $segtree[l] = [$segtree[l], val].min
      l += 1
    end
    if r & 1 > 0
      $segtree[r - 1] = [$segtree[r - 1], val].min
      r -= 1
    end
    l /= 2
    r /= 2
  end
end

def get i
  res = 1e9
  i += N
  while i > 0
    res = [res, $segtree[i]].min
    i /= 2
  end
  res
end

r = *0...N

A.map.with_index do |(a,b),h|
  chmin a, b + 1, get(a - 1)
  i = r.bsearch{ get(_1) > 0 }
  puts i ? i + 1 - get(i) + h : -1
  # p [$segtree, r.map{get _1}]
end
