#include #include using namespace std; using ll = long long; using S = array; S op(S l, S r){ l[0] += r[0]; l[1] += r[1]; l[2] += r[2]; return l; } S e(){return S({0,0,0});} using F = int; S mapping(F f, S x){ if(f == -1)return x; int s = x[0] + x[1] + x[2]; fill(x.begin(), x.end(), 0); x[f] = s; return x; } F composition(F f, F g){ if(f == -1)return g; return f; } F id(){ return -1; } int main(){ int N, Q, x, l, r; cin >> N >> Q; long long A = 0, B = 0; atcoder::lazy_segtree seg(vector(N, S({0, 0, 1}))); while(Q--){ cin >> x >> l >> r; r++; if(x)seg.apply(l,r,x-1); else{ auto b = seg.prod(l,r); if(b[0] > b[1])A += b[0]; if(b[1] > b[0])B += b[1]; } } auto b = seg.all_prod(); A += b[0], B += b[1]; cout << A << " " << B << '\n'; }