module type LazySegtreeType = sig
    type s
    type f
    type t

    val make     : int -> t
    val of_array : s array -> t
    val set      : t -> int -> s -> unit
    val get      : t -> int -> s
    val prod     : t -> int -> int -> s
    val all_prod : t -> s
    val apply1   : t -> int -> f -> unit
    val apply    : t -> int -> int -> f -> unit
    val max_right: t -> int -> (s -> bool) -> int
    val min_left : t -> int -> (s -> bool) -> int
end

module type LazySegtreeParam = sig
    type s
    type f

    val op         : s -> s -> s
    val e          : s
    val mapping    : f -> s -> s
    val composition: f -> f -> f 
    val id         : f
end

module LazySegtree = struct
    module Make(LSP: LazySegtreeParam) :
        LazySegtreeType with type s = LSP.s and
                             type f = LSP.f = struct
        type s = LSP.s
        type f = LSP.f
        type t = int * int * int * s array * f array

        let ceil_pow2 n =
            let rec loop x =
                if 1 lsl x < n then loop (x + 1) else x
            in
            loop 0

        let update d k = d.(k) <- LSP.op d.(2 * k) d.(2 * k + 1)

        let all_apply (n, log, size, d, lz) k f =
            d.(k) <- LSP.mapping f d.(k);
            if k < size then lz.(k) <- LSP.composition f lz.(k)

        let push ((n, log, size, d, lz) as lst) k =
            all_apply lst (2 * k)     lz.(k);
            all_apply lst (2 * k + 1) lz.(k);
            lz.(k) <- LSP.id

        let of_array v =
            let n = Array.length v in
            let log = ceil_pow2 n in
            let size = 1 lsl log in
            let d = Array.make (2 * size) LSP.e in
            let lz = Array.make size LSP.id in
            for i = 0 to n - 1 do d.(size + i) <- v.(i) done;
            for i = size - 1 downto 1 do update d i done;
            n, log, size, d, lz

        let make n = of_array (Array.make n LSP.e)

        let set ((n, log, size, d, lz) as lst) p x =
            let p = p + size in
            for i = log downto 1 do push lst (p lsr i) done;
            d.(p) <- x;
            for i = 1 to log do update d (p lsr i) done

        let get ((n, log, size, d, lz) as lst) p =
            let p = p + size in
            for i = log downto 1 do push lst (p lsr i) done;
            d.(p)

        let prod ((n, log, size, d, lz) as lst) l r =
            if l = r then LSP.e else (
                let l = l + size in
                let r = r + size in
                for i = log downto 1 do
                    if (l lsr i) lsl i <> l then push lst (l lsr i);
                    if (r lsr i) lsl i <> r then push lst (r lsr i);
                done;

                let rec loop l r sml smr =
                    if l >= r then LSP.op sml smr else
                        let sml, l = if l land 1 = 0 then sml, l else LSP.op sml d.(l),     l + 1 in
                        let smr, r = if r land 1 = 0 then smr, r else LSP.op d.(r - 1) smr, r - 1 in 
                        loop (l lsr 1) (r lsr 1) sml smr
                in
                loop l r LSP.e LSP.e
            )

        let all_prod (n, log, size, d, lz) = d.(1)

        let apply1 ((n, log, size, d, lz) as lst) p f =
            let p = p + size in
            for i = log downto 1 do push lst (p lsr i) done;
            d.(p) <- LSP.mapping f d.(p);
            for i = 1 to log do update d (p lsr i) done

        let apply ((n, log, size, d, lz) as lst) l r f =
            if l <> r then (
                let l = l + size in
                let r = r + size in
                for i = log downto 1 do
                    if (l lsr i) lsl i <> l then push lst (l lsr i);
                    if (r lsr i) lsl i <> r then push lst ((r - 1) lsr i);
                done;

                let rec loop l r =
                    if l < r then (
                        let l = if l land 1 = 0 then l else (all_apply lst l       f; l + 1) in
                        let r = if r land 1 = 0 then r else (all_apply lst (r - 1) f; r - 1) in
                        loop (l lsr 1) (r lsr 1)
                    )
                in
                loop l r;

                for i = 1 to log do
                    if (l lsr i) lsl i <> l then update d (l lsr i);
                    if (r lsr i) lsl i <> r then update d ((r - 1) lsr i);
                done
            )

        let max_right ((n, log, size, d, lz) as lst) l g =
            if l = n then n else (
                let l = l + size in
                for i = log downto 1 do push lst (l lsr i) done;
                let rec loop l sm =
                    let l =
                        let rec div2 l =
                            if l mod 2 = 0 then div2 (l lsr 1) else l
                        in
                        div2 l
                    in
                    if not (g (LSP.op sm d.(l))) then (
                        let rec loop2 l sm =
                            if l < size then (
                                push lst l;
                                let l = 2 * l in
                                if g (LSP.op sm d.(l)) then
                                    loop2 (l + 1) (LSP.op sm d.(l))
                                else loop2 l sm
                            ) else l - size
                        in
                        loop2 l sm
                    ) else (
                        let sm = LSP.op sm d.(l) in
                        let l = l + 1 in
                        if l land (-l) <> l then loop l sm else n
                    )
                in
                loop l LSP.e
            )

        let min_left ((n, log, size, d, lz) as lst) r g =
            if r = 0 then 0 else (
                let r = r + size in
                for i = log downto 1 do push lst ((r - 1) lsr i) done;
                let rec loop r sm =
                    let r = 
                        let rec div2 r = 
                            if r > 1 && r mod 2 = 1 then div2 (r lsr 1) else r
                        in  
                        div2 (r - 1)
                    in
                    if not (g (LSP.op d.(r) sm)) then (
                        let rec loop2 r sm =
                            if r < size then (
                                push lst r;
                                let r = 2 * r + 1 in
                                if g (LSP.op d.(r) sm) then
                                    loop2 (r - 1) (LSP.op d.(r) sm)
                                else loop2 r sm
                            ) else r + 1 - size
                        in
                        loop2 r sm
                    ) else (
                        let sm = LSP.op d.(r) sm in
                        if r land (-r) <> r then loop r sm else 0
                    )
                in
                loop r LSP.e
            )
    end
end;;
Scanf.scanf "%d %d" (fun n q ->
    let z = 998244353 in
    let ten = Array.make n 1 in
    let one = Array.make n 0 in 
    for i = 1 to n - 1 do ten.(i) <- (ten.(i - 1) * 10) mod z done;
    for i = 1 to n - 1 do one.(i) <- (one.(i - 1) * 10 + 1) mod z done;
    let module ST = LazySegtree.Make (struct
        type s = int * int
        let op (ll, lv) (rl, rv) = ll + rl, (lv * ten.(rl) + rv) mod z
        let e = 0, 0
        type f = int
        let mapping f ((sl, sv) as s) = if f = 0 then s else sl, (one.(sl) * f) mod z
        let composition l r = if l = 0 then r else l
        let id = 0
    end)
        in
    let seg = ST.of_array (Array.make n (1, 1)) in
    for i = 1 to q do
        Scanf.scanf " %d %d %d" (fun l r d ->
            ST.apply seg (l - 1) r d;
            let (_, v) = ST.all_prod seg in
            Printf.printf "%d\n" v
        )
    done
)

Measured memory_bytes: 42548