Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353
n, q = map(int, input().split())


class LazySegTree:
    def __init__(self, N):
        self.INF = 2**31-1
        self.N = N
        self.LV = (self.N - 1).bit_length()
        self.N0 = 2 ** self.LV
        self.data = [0] * (2 * self.N0)
        self.lazy = [0] * (2 * self.N0)
        self.size = [0] * (2 * self.N0)
        val = 1
        for i in range(self.N):
            self.size[self.N0 + self.N - 2 - i] = val
            val = val * 10 % mod
        for i in range(self.N0 - 2, -1, -1):
            self.size[i] = (self.size[2 * i + 1] + self.size[2 * i + 2]) % mod

    def gindex(self, l, r):
        L = (l + self.N0) >> 1; R = (r + self.N0) >> 1
        lc = 0 if l & 1 else (L & -L).bit_length()
        rc = 0 if r & 1 else (R & -R).bit_length()
        for i in range(self.LV):
            if rc <= i:
                yield R
            if L < R and lc <= i:
                yield L
            L >>= 1; R >>= 1

    # 遅延伝搬処理
    def propagates(self, *ids):
        for i in reversed(ids):
            v = self.lazy[i-1]
            if not v:
                continue
            self.lazy[2*i-1] = v; self.lazy[2*i] = v
            self.data[2*i-1] = v * self.size[2*i-1] % mod
            self.data[2*i] = v * self.size[2*i] % mod
            self.lazy[i-1] = 0

    # 区間[l, r)にxを加算
    def update(self, l, r, x):
        *ids, = self.gindex(l, r)
        self.propagates(*ids)

        L = self.N0 + l; R = self.N0 + r
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R-1] = x; self.data[R-1] = x * self.size[R-1] % mod
            if L & 1:
                self.lazy[L-1] = x; self.data[L-1] = x * self.size[L-1] % mod
                L += 1
            L >>= 1; R >>= 1
        for i in ids:
            self.data[i-1] = (self.data[2*i-1] + self.data[2*i]) % mod

    # 区間[l, r)内の最小値を求める
    def query(self, l, r):
        self.propagates(*self.gindex(l, r))
        L = self.N0 + l; R = self.N0 + r

        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = (s + self.data[R-1]) % mod
            if L & 1:
                s = (s + self.data[L-1]) % mod
                L += 1
            L >>= 1; R >>= 1
        return s


lst = LazySegTree(n)
lst.update(0, n, 1)

for _ in range(q):
    l, r, d = map(int, input().split())
    l -= 1
    lst.update(l, r, d)
    print(lst.query(0, n))


Fixed submission:
import sys
input = sys.stdin.readline

mod = 998244353
n, q = map(int, input().split())


class LazySegTree:
    def __init__(self, N):
        self.INF = 2**31-1
        self.N = N
        self.LV = (self.N - 1).bit_length()
        self.N0 = 2 ** self.LV
        self.data = [0] * (2 * self.N0)
        self.lazy = [0] * (2 * self.N0)
        self.size = [0] * (2 * self.N0)
        val = 1
        for i in range(self.N):
            self.size[self.N0 + self.N - 2 - i] = val
            val = val * 10 % mod
        for i in range(self.N0 - 2, -1, -1):
            self.size[i] = (self.size[2 * i + 1] + self.size[2 * i + 2]) % mod

    def gindex(self, l, r):
        L = (l + self.N0) >> 1; R = (r + self.N0) >> 1
        lc = 0 if l & 1 else (L & -L).bit_length()
        rc = 0 if r & 1 else (R & -R).bit_length()
        for i in range(self.LV):
            if rc <= i:
                yield R
            if L < R and lc <= i:
                yield L
            L >>= 1; R >>= 1

    # 遅延伝搬処理
    def propagates(self, *ids):
        for i in reversed(ids):
            v = self.lazy[i-1]
            if not v:
                continue
            self.lazy[2*i-1] = v; self.lazy[2*i] = v
            self.data[2*i-1] = v * self.size[2*i-1] % mod
            self.data[2*i] = v * self.size[2*i] % mod
            self.lazy[i-1] = 0

    # 区間[l, r)にxを加算
    def update(self, l, r, x):
        *ids, = self.gindex(l, r)
        self.propagates(*ids)

        L = self.N0 + l; R = self.N0 + r
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R-1] = x; self.data[R-1] = x * self.size[R-1] % mod
            if L & 1:
                self.lazy[L-1] = x; self.data[L-1] = x * self.size[L-1] % mod
                L += 1
            L >>= 1; R >>= 1
        for i in ids:
            self.data[i-1] = (self.data[2*i-1] + self.data[2*i]) % mod

    # 区間[l, r)内の最小値を求める
    def query(self, l, r):
        self.propagates(*self.gindex(l, r))
        L = self.N0 + l; R = self.N0 + r

        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = (s + self.data[R-1]) % mod
            if L & 1:
                s = (s + self.data[L-1]) % mod
                L += 1
            L >>= 1; R >>= 1
        return s


lst = LazySegTree(n)
lst.update(0, n, 1)

for _ in range(q):
    l, r, d = map(int, input().split())
    l -= 1
    lst.update(l, r, d)
    print(lst.query(0, n))