H, W = gets.split.map(&:strip).map(&:to_i)
A = Array.new(H)
B = Array.new(H)
H.times do |i|
  A[i], B[i] = gets.split.map(&:strip).map(&:to_i)
end

M = 10**6
INF = 10**10


def solve(k)
  m = Array.new(W, 0)
  w = (1..W).to_a
  ii = W
  vk = 1
  while vk <= k
    i = 0
    while w[i] < A[vk-1]
      i += 1
    end
    if B[vk-1] == W
      ii = i
    elsif i < ii
      if w[i] <= B[vk-1]
        w[i] = B[vk-1] + 1
        i += 1
        j = i
        while j < ii && w[j] <= B[vk-1]
          j += 1
        end
        while j < ii
          w[i] = w[j]
          i+= 1
          j+= 1
        end
        ii = i
      end
    end
    if ii > 0
      ans = w[0...ii].min_by.with_index{|w,i| w-i} -1 + vk
      if ans < INF
        puts ans
      else
        puts -1
      end
    else
      puts -1
    end
    vk += 1
  end
end

solve(H)
