program i_hate_shortest_path_problem
  implicit none
  integer, parameter :: inf = 1e9
  integer :: h, w, a, b, m, i, j, l, r, u
  integer, allocatable :: x(:)
  read(*,*) h, w
  allocate(x(2 * w))
  x = [(i, i = 1, 2 * w)]
  u = w
  do i = 1, h
    read(*,*) a, b
    if (x(1) > w) then
      write(*,'(i0)') -1
      cycle
    end if
    l = lower_bound(a)
    r = upper_bound(b)
    x(r) = b + 1
    x(l:r - 1) = x(r:2 * r - l + 1)
    do while (x(u) > w)
      u = u - 1
    end do
    m = inf
    do j = 1, u
      m = min(m, x(j) - j + i)
    end do
    write(*,'(i0)') merge(-1, m, m == inf)
  end do
contains
  integer function lower_bound(n) result(res)
    integer, intent(in) :: n
    integer :: l, r, m
    l = 0
    r = u + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (x(m) < n) then
        l = m
      else
        r = m
      end if
    end do
    res = r
  end
  integer function upper_bound(n) result(res)
    integer, intent(in) :: n
    integer :: l, r, m
    l = 0
    r = u + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (x(m) > n) then
        r = m
      else
        l = m
      end if
    end do
    res = l
  end
end program i_hate_shortest_path_problem