#include // {{{ // clang-format off #pragma GCC optimize "O3,omit-frame-pointer,inline" #pragma GCC target "tune=native" #define ARG4(_1, _2, _3, _4, ...) _4 #define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__) #define REP(i, a) FOR(i, 0, a) #define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i) #define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__) #define RREP(i, a) RFOR(i, 0, a) #define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i) #define ALL(c) (c).begin(), (c).end() #define TEN(n) ((ll)(1e##n)) #define pb emplace_back #define mp make_pair #define fi first #define se second #define USE1(T) templateinline #define USE2(T, U) templateinline #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) templateusing duo=std::pair; templateusing vec=std::vector; using ll=long long; using pii=duo; USE2(T,U)bool chmax(T&x,U a){return x>x;return x;} USE1(T=int)vecin(int n){vecv;v.reserve(n);rep(i,n)v.pb(in());return v;} USE1(T=int)vecin(int n,T a){vecv;v.reserve(n);rep(i,n)v.pb(in()+a);return v;} USE1(T)vec>enume(const vec&x,int s=0){int N=x.size();vec>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;} USE1(T)vecndvec(T v,int n){return vec(n,v);} USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec{return ndvec(ndvec(v,ns...),n);} USE1(T)void pr(T x){std::cout< namespace copr { namespace seg_util { constexpr int nextpow2(int x, int r = 1) { return r < x ? nextpow2(x, r + r) : r; } } // namespace seg_util template struct LazySegTree { using data_type = typename Monoid::value_type; using lazy_type = typename Lazy::value_type; const int N; const data_type empty = Monoid::empty(); const lazy_type nil = Lazy::empty(); std::vector data; std::vector lazy; LazySegTree(int size) : N(seg_util::nextpow2(size)) { data.assign(N * 2, empty); lazy.assign(N * 2, nil); } inline void propagate(int x, int l, int r) { if (lazy[x] == nil) return; data[x] = Lazy::eval(data[x], lazy[x], l, r); if (x < N - 1) { lazy[x + x + 1] = Lazy::append(lazy[x + x + 1], lazy[x]); lazy[x + x + 2] = Lazy::append(lazy[x + x + 2], lazy[x]); } lazy[x] = nil; } void query(lazy_type v, int a, int b) { query(v, a, b, 0, 0, N); } void query(lazy_type v, int a, int b, int x, int l, int r) { propagate(x, l, r); if (r <= a || b <= l) return; if (a <= l && r <= b) { lazy[x] = Lazy::append(lazy[x], v); propagate(x, l, r); return; } int m = (l + r) / 2; query(v, a, b, x + x + 1, l, m); query(v, a, b, x + x + 2, m, r); data[x] = Monoid::append(data[x + x + 1], data[x + x + 2]); } data_type concat(int a, int b) { return concat(a, b, 0, 0, N); } data_type concat(int a, int b, int x, int l, int r) { propagate(x, l, r); if (r <= a || b <= l) return empty; if (a <= l && r <= b) return data[x]; int m = (l + r) / 2; return Monoid::append(concat(a, b, x + x + 1, l, m), concat(a, b, x + x + 2, m, r)); } }; } // namespace copr using namespace std; const int inf = 1001001001; const ll infl = 1001001001001001001ll; const int dd[] = {0, 1, 0, -1, 0}; struct Sum { using value_type = int; static value_type append(value_type a, value_type b) { return a + b; } static value_type empty() { return 0; } struct FillQuery { using value_type = int; static value_type append(value_type a, value_type b) { return b; } static value_type empty() { return -1; } template static T eval(T v, value_type x, int l, int r) { return x * (r - l); } }; }; signed main() { // int N = rd(); int Q = rd(); copr::LazySegTree A{N}, B{N}; ll a = 0, b = 0; rep(i, Q) { int x = rd(), l = rd(), r = rd() + 1; if (x == 0) { auto ac = A.concat(l, r); auto bc = B.concat(l, r); if (ac == bc) continue; if (ac < bc) { b += bc; } else { a += ac; } } else { A.query(x == 1, l, r); B.query(x == 2, l, r); } } a += A.concat(0, N); b += B.concat(0, N); wr(a, ' '); wr(b); return 0; }