local mmi, mma = math.min, math.max
local h, w = io.read("*n", "*n")
local a, b = {}, {}
for i = 1, h do
  a[i], b[i] = io.read("*n", "*n")
end
if a[1] == 1 and b[1] == w then
  for i = 1, h do
    print(-1)
  end
  os.exit()
end

local asked_by_depth = {}
for i = 1, h do
  asked_by_depth[i] = {}
end
local inf = 1000000007
local ret = {}
for i = 1, h + 1 do
  ret[i] = inf
end
local function solve(spos)
  local th = h
  local curpos = spos
  local t = {curpos}
  for i = 1, h do
    if curpos < a[i] or b[i] < curpos then
    else
      if b[i] == w then
        th = i - 1 break
      end
      curpos = b[i] + 1
    end
    t[i + 1] = curpos
  end
  -- print(th, table.concat(t, " "))
  for i = th, 1, -1 do
    if curpos < a[i] or b[i] < curpos then
    else
      curpos = a[i] - 1
    end
  end
  spos = curpos
  for i = 1, th do
    if curpos < a[i] or b[i] < curpos then
    else
      curpos = b[i] + 1
    end
    ret[i] = mmi(ret[i], i + curpos - spos)
  end
end

if 1 < a[1] then
  solve(1)
end
if b[1] < w then
  solve(b[1] + 1)
end
for i = 1, h do
  if ret[i] == inf then ret[i] = -1 end
end
ret[h + 1] = nil
print(table.concat(ret, "\n"))
