type Segtree() = let n = 1 <<< 17 let dat = Array.zeroCreate (n * 2) let lz = Array.create (n * 2) -1 member this.N with get() = n member this.Dat with get() = dat member this.Lazy with get() = lz member this.SetLazy k v s = this.Dat.[k] <- v * s this.Lazy.[k] <- v member this.Push k s = if this.Lazy.[k] <> -1 then this.SetLazy (k * 2 + 0) this.Lazy.[k] (s / 2) this.SetLazy (k * 2 + 1) this.Lazy.[k] (s / 2) this.Lazy.[k] <- -1 member this.RecFill ql qr v k nl nr = if ql <= nl && nr <= qr then this.SetLazy k v (nr - nl) else let nm = (nl + nr) / 2 this.Push k (nr - nl) if ql < nm then this.RecFill ql qr v (k * 2 + 0) nl nm if qr > nm then this.RecFill ql qr v (k * 2 + 1) nm nr this.Dat.[k] <- this.Dat.[k * 2] + this.Dat.[k * 2 + 1] member this.Fill ql qr v = this.RecFill ql qr v 1 0 this.N member this.RecSum ql qr k nl nr = if ql <= nl && nr <= qr then this.Dat.[k] elif nr <= ql || qr <= nl then 0 else this.Push k (nr - nl) let nm = (nl + nr) / 2 let vl = this.RecSum ql qr (k * 2 + 0) nl nm let vr = this.RecSum ql qr (k * 2 + 1) nm nr vl + vr member this.Sum ql qr = this.RecSum ql qr 1 0 this.N let N = System.Console.ReadLine() |> int let Q = System.Console.ReadLine() |> int let segA = new Segtree() let segB = new Segtree() let mutable scoreA : int64 = 0L let mutable scoreB : int64 = 0L for _ in 1 .. Q do let x, l, r = System.Console.ReadLine().Split() |> Array.map int |> fun a -> a.[0], a.[1], a.[2] if x = 0 then let a = segA.Sum l (r + 1) let b = segB.Sum l (r + 1) if a > b then scoreA <- scoreA + int64(a) if a < b then scoreB <- scoreB + int64(b) elif x = 1 then segA.Fill l (r + 1) 1 segB.Fill l (r + 1) 0 else segA.Fill l (r + 1) 0 segB.Fill l (r + 1) 1 scoreA <- scoreA + int64(segA.Sum 0 N) scoreB <- scoreB + int64(segB.Sum 0 N) printfn "%d %d" scoreA scoreB