struct S{ int f,x,y; }; inline S segtree_ph_func(S a,S b){ return {a.f^b.f,(b.f?a.y:a.x)+b.x,(b.f?a.x:a.y)+b.y}; } { segtree_pht; ll@n,@q; t.walloc(n+2,1); rep(i,n+2){ t[i]={0,0,1}; } t.build(); rep(q){ ll@l,@r; { S s=t[l-1]; s.f^=1; t.change(l-1,s); } { S s=t[r]; s.f^=1; t.change(r,s); } wt(t.get(0,n+2).x); } }