#include using namespace std; #define REP(i,a,b) for(i=a;i'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template void reader(T *x, S *y){reader(x);reader(y);} template void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template void writerLn(T x){writer(x,'\n');} template void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} char memarr[17000000]; void *mem = memarr; #define MD 1000000007 template struct mypair{ T first; S second; mypair(void){}; mypair(T a, S b){first=a;second=b;} mypair &operator+=(mypair a){ first += a.first; second += a.second; return *this; } mypair &operator-=(mypair a){ first -= a.first; second -= a.second; return *this; } mypair operator+(mypair a){ return mypair(*this)+=a; } mypair operator-(mypair a){ return mypair(*this)-=a; } mypair &operator*=(int a){ first *= a; second *= a; return *this; } mypair operator*(int a){ return mypair(*this)*=a; } mypair &operator=(int a){ first = a; second = a; return *this; } bool operator==(int a){ return first==a && second==a; } bool operator!=(int a){ return first!=a || second!=a; } }; template mypair operator*(int a, mypair b){b.first*=a;b.second*=a;return b;} template struct lazySegtreeSum{ int N, logN; T *data; T *fixval; char *fixed; void malloc(int maxN){ int i; for(i=1;i 1){ fixed[a*2] = fixed[a*2+1] = 1; fixval[a*2] = fixval[a*2+1] = fixval[a]; data[a*2] = data[a*2+1] = sz * fixval[a]; } else { data[a*2] = data[a*2+1] = fixval[a]; } fixed[a] = 0; } } inline void push(int a){ int i, aa; for(i=logN;i;i--){ aa = a>>i; push_one(aa, 1<<(i-1)); } } inline void build(int a){ int sz = 1; while(a > 1){ a /= 2; sz *= 2; if(fixed[a]){ data[a] = fixval[a] * sz; } else { data[a] = data[a*2] + data[a*2+1]; } } } inline void change(int a, int b, T val){ int sz = 1, aa, bb; if(a >= b) return; aa = (a += N); bb = (b += N); push(a); push(b-1); if(a%2) data[a++] = val; if(b%2) data[--b] = val; a /= 2; b /= 2; while(a < b){ sz *= 2; if(a%2) fixed[a]=1, fixval[a]=val, data[a++] = sz*val; if(b%2) fixed[--b]=1, fixval[b]=val, data[b] = sz*val; a /= 2; b /= 2; } build(aa); build(bb-1); } inline T getSum(int a, int b){ T res; int sz = 1; a += N; b += N; push(a); push(b-1); res = 0; while(a < b){ if(a%2) res += data[a++]; if(b%2) res += data[--b]; a /= 2; b /= 2; } return res; } }; int N, Q; int X, L, R; int main(){ int i, j, k, v1, v2; ll s1=0, s2=0; mypair a; lazySegtreeSum > t; reader(&N,&Q); t.malloc(N); t.setN(N); t.build(); while(Q--){ reader(&X,&L,&R); R++; if(X==0){ a = t.getSum(L, R); if(a.first > a.second) s1 += a.first; if(a.first < a.second) s2 += a.second; } else if(X==1){ t.change(L, R, mypair(1,0)); } else if(X==2){ t.change(L, R, mypair(0,1)); } } a = t.getSum(0, N); s1 += a.first; s2 += a.second; writerLn(s1,s2); return 0; }