use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let n: Vec = s.split_whitespace().flat_map(str::parse).collect(); let (mut a, mut d) = (0, vec![0; n[0]]); for i in n[2..].chunks(2) { for d in d[i[0] - 1..i[1]].iter_mut() { a -= *d; *d ^= 1; a += *d; } println!("{a}") } }