let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let as_ = Array.make h 0 in
  let bs = Array.make h 0 in
  for i = 0 to h - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      as_.(i) <- a;
      bs.(i) <- b
  done;
  let dp = Array.make (h + 1) 1 in
  for i = 0 to h - 1 do
    dp.(i + 1) <- if dp.(i) < as_.(i) then dp.(i) else bs.(i) + 1
  done;
  let dp' = Array.make (h + 1) w in
  for i = h - 1 downto 0 do
    dp'.(i) <- if bs.(i) < dp.(i + 1) then dp.(i + 1) else as_.(i) - 1
  done;
  for i = 1 to h do
    Printf.printf "%d\n" @@
    if w < dp.(i)
    then -1
    else i + min (dp.(i) - 1) (dp'.(i) - dp'.(0))
  done
