N, Q = gets.split(" ").map{|s| s.to_i} lamp = Array.new(N, false) cnt = 0 ans = [] Q.times { l, r = gets.split(" ").map{|s| s.to_i} (l-1).upto(r-1) {|i| if lamp[i] then cnt -= 1 else cnt += 1 end lamp[i] = !lamp[i] } ans << cnt } puts ans