#include #define rep(i, n) for (int i = 0; i < (n); ++i) using std::cin; using std::cout; using std::vector; int main() { int n, q; cin >> n >> q; vector a(n); int sum = 0; while (q--) { int l, r; cin >> l >> r; --l; for (int i = l; i < r; ++i) { sum -= a[i]; a[i] ^= 1; sum += a[i]; } cout << sum << '\n'; } return 0; }