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

ary = [1, 0]

h.times do
    a, b = gets.split.map(&:to_i)
    
    if a > ary[0]
        ary[1] += 1
    elsif b == w || ary[1] == -1
        ary = [w + 1, -1]
    else
        ary[1] += b - ary[0] + 2
        ary[0] = b + 1
    end

    puts ary[1]
end