h, w = gets.split.map(&:to_i)

ary = [[1, w, 0], [w+1, w+1, 1 << 30]] # l, r, c
h.times do |i|
    t = []
    a, b = gets.split.map(&:to_i)

    x = ary.bsearch_index{|l,r,c| l >= a}
    y = ary.bsearch_index{|l,r,c| l > b}

    if x > 0
        t = ary[0..x-2] if x > 1
        
        if ary[x][0] <= b
            l, r, c = ary[x-1]
            if r < a
                t << [l, r, c]
            elsif l < a
                t << [l, a-1, c]
            end
        end
    end

    if y > 0
        l, r, c = ary[y-1]
        if x == y
            if r < a
                t << [l, r, c]
            elsif r <= b
                t << [l, a-1, c]
            else
                t << [l, a-1, c]
                t << [b+1, r, c]
            end
        elsif r <= b
            if ary[y][0] > b + 1
                t << [b+1, b+1, c + b - r + 1]
            end
        else
            t << [b+1, r, c]
        end
    end
    t += ary[y..-1]

    ary = t
    ans = ary.min_by{|l,r,c| c}[2]
    puts ans == 1 << 30 ? -1 : ans + i + 1
end
