header_code = """
#include "/opt/ac-library/atcoder/lazysegtree.hpp"
#include "/opt/ac-library/atcoder/modint.hpp"
#include <vector>
#include <algorithm>
#include <cassert>

namespace aclython {

using mint = atcoder::modint998244353;

const mint inv_nine = mint(1)/mint(9);

struct S {
    mint a;
    mint b;
    S(mint _a, mint _b) : a(_a) ,b(_b) {}
    S(int _a, int _b) : a(_a) ,b(_b) {}
    S(const S &s) : a(s.a), b(s.b) {}
    int get_a() { return (int)a.val(); }
};

struct F {
    mint a;
    F(mint _a) : a(_a) {}
    F(int _a) : a(_a) {}
};


S op(S l, S r) { return S{l.a * r.b + r.a, l.b * r.b}; }

S e() { return S{0, 1}; }

S mapping(F l, S r) {
    if (l.a==0) return r;
    return S{l.a * (r.b - 1)*inv_nine, r.b};
    }

F composition(F l, F r) {
    if (l.a==0) return r;
    return l;
    }

F id() { return F{0}; }

struct lazy_segtree{
    lazy_segtree() : lazy_segtree(0) {}
    lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
    lazy_segtree(const std::vector<S>& vec) : seg(vec) {}
    void set(int p, S x) { seg.set(p, x); }
    S get(int p) { return seg.get(p); }
    S prod(int l, int r) { return seg.prod(l, r); }
    S all_prod() { return seg.all_prod(); }
    void apply(int p, F f) { seg.apply(p, f); }
    void apply(int l, int r, F f) { seg.apply(l, r, f); }
    private:
        atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg;
};

}
"""

code = """

# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/ac-library]
# cython: boundscheck=False
# cython: wraparound=False

from libcpp.string cimport string
from libcpp.vector cimport vector
from libc.stdio cimport getchar, printf
from libcpp cimport bool

cdef extern from "./intermediate.hpp" namespace "aclython" nogil:
    cdef cppclass S:
        S(int, int)
        S(S &)
        int get_a()
    cdef cppclass F:
        F(int)
    cdef cppclass lazy_segtree:
        lazy_segtree(vector[S] v)
        void set(int p, S x)
        S get(int p)
        S prod(int l, int r)
        S all_prod()
        void apply(int p, F f)
        void apply(int l, int r, F f)

cdef class LazySegTree:
    cdef lazy_segtree *_thisptr
    def __cinit__(self, vector[vector[int]] v):
        cdef int n = v.size()
        cdef vector[S] *sv = new vector[S]()
        cdef S *s
        for i in range(n):
            s = new S(v.at(i).at(0), v.at(i).at(1))
            sv.push_back(s[0])
        self._thisptr = new lazy_segtree(sv[0])
    cpdef void set(self, int p, vector[int] v):
        cdef S *s = new S(v.at(0), v.at(1))
        self._thisptr.set(p, s[0])
    cpdef int get(self, int p):
        cdef S *s = new S(self._thisptr.get(p))
        return s.get_a()
    cpdef int prod(self, int l, int r):
        cdef S *s = new S(self._thisptr.prod(l, r))
        return s.get_a()
    cpdef int all_prod(self):
        cdef S *s = new S(self._thisptr.all_prod())
        return s.get_a()
    cpdef void apply(self, int p, int _f):
        cdef F *f = new F(_f)
        self._thisptr.apply(p, f[0])
    cpdef void apply_range(self, int l, int r, int _f):
        cdef F *f = new F(_f)
        self._thisptr.apply(l, r, f[0])
cpdef inline vector[int] ReadInt(int n):
    cdef int b, c
    cdef vector[int] *v = new vector[int]()
    for i in range(n):
        c = 0
        while 1:
            b = getchar() - 48
            if b < 0: break
            c = c * 10 + b
        v.push_back(c)
    return v[0]

cpdef inline vector[string] Read(int n):
    cdef char c
    cdef vector[string] *vs = new vector[string]()
    cdef string *s
    for i in range(n):
        s = new string()
        while 1:
            c = getchar()
            if c<=32: break
            s.push_back(c)
        vs.push_back(s[0])
    return vs[0]

cpdef inline void PrintLongN(vector[long] l):
    cdef int n = l.size()
    for i in range(n): printf("%ld\\n", l[i])

cpdef inline void PrintLong(vector[long] l):
    cdef int n = l.size()
    for i in range(n): printf("%ld ", l[i])
"""


import os, sys, getpass

if sys.argv[-1] == 'ONLINE_JUDGE':
    code = code.replace("USERNAME", getpass.getuser())
    open('intermediate.hpp','w').write(header_code)
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
    sys.exit(0)


from atcoder import LazySegTree, ReadInt

def main():
    N,Q = ReadInt(2)
    lst = LazySegTree([(1,10) for i in range(N)])
    for i in range(Q):
        l,r,d = ReadInt(3)
        lst.apply_range(l-1,r,d)
        print(lst.all_prod())

if __name__ == "__main__":
    main()

Measured memory_bytes: 49508