Language: C++

import os
import sys
from io import BytesIO, IOBase


class LazySegmentTree:
    def __init__(self, data, default=[0, 0]):
        """initialize the lazy segment tree with data"""
        self.MOD = 998244353
        self.precompute = [0] * (len(data) + 1)
        self.precompute[1] = 1
        for i in range(1, len(data) + 1):
            self.precompute[i] = (self.precompute[i - 1] * 10 + 1) % self.MOD
        
        self._default = default

        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()
        self._lazy = [0] * (2 * _size)

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = self._func(self.data[i + i], self.data[i + i + 1])
        
    
    def _func(self, a, b):
        return [(a[0] * pow(10, b[1], self.MOD) + b[0]) % self.MOD, a[1] + b[1]]

    def __len__(self):
        return self._len

    def _push(self, idx):
        """push query on idx to its children"""
        # Let the children know of the queries
        q, self._lazy[idx] = self._lazy[idx], 0

        self._apply(2 * idx, q)
        self._apply(2 * idx + 1, q)

    def _apply(self, idx, tag):
        if tag == 0: return
        self._lazy[idx] = tag
        self.data[idx][0] = tag * self.precompute[self.data[idx][1]] % self.MOD

    def _update(self, idx):
        """updates the node idx to know of all queries applied to it via its ancestors"""
        for i in reversed(range(1, idx.bit_length())):
            self._push(idx >> i)

    def _build(self, idx):
        """make the changes to idx be known to its ancestors"""
        idx >>= 1
        while idx:
            if self._lazy[idx] == 0:
                self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            # else:
            #     self.data[idx][0] = self._lazy[idx] * self.precompute[self.data[idx][1]] % self.MOD
            idx >>= 1

    def update(self, start, stop, value):
        """lazily add value to [start, stop)"""
        start = start_copy = start + self._size
        stop = stop_copy = stop + self._size
        while start < stop:
            if start & 1:
                self._apply(start, value)
                start += 1
            if stop & 1:
                stop -= 1
                self._apply(stop, value)
            start >>= 1
            stop >>= 1

        # Tell all nodes above of the updated area of the updates
        self._build(start_copy)
        self._build(stop_copy - 1)

    def query(self, start, stop):
        """func of data[start, stop)"""
        start += self._size
        stop += self._size

        # Apply all the lazily stored queries
        self._update(start)
        self._update(stop - 1)

        resL = [0, 0]
        resR = [0, 0]
        while start < stop:
            if start & 1:
                resL = self._func(resL, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                resR = self._func(self.data[stop], resR)
            start >>= 1
            stop >>= 1
        return self._func(resL, resR)[0]

    def __repr__(self):
        return "LazySegmentTree({0})".format(self.data)

def main():
    n, q = getints()
    data = [[1, 1] for _ in range(n)]
    st = LazySegmentTree(data)
    while q:
        L, R, D = getints()
        st.update(L - 1, R, D)
        # print(st)
        print(st.query(0, n))
        q -= 1


# region fastio


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input(): return sys.stdin.readline().rstrip("\r\n")
def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint1(): return list(map(lambda x: int(x) - 1, input().split()))


# endregion


if __name__ == "__main__":
    main()

Compiler output:
a.cc:35:11: error: invalid preprocessing directive #Let
   35 |         # Let the children know of the queries
      |           ^~~
a.cc:57:15: error: #else without #if
   57 |             # else:
      |               ^~~~
a.cc:58:19: error: invalid preprocessing directive #self
   58 |             #     self.data[idx][0] = self._lazy[idx] * self.precompute[self.data[idx][1]] % self.MOD
      |                   ^~~~
a.cc:75:11: error: invalid preprocessing directive #Tell
   75 |         # Tell all nodes above of the updated area of the updates
      |           ^~~~
a.cc:84:11: error: invalid preprocessing directive #Apply
   84 |         # Apply all the lazily stored queries
      |           ^~~~~
a.cc:111:11: error: invalid preprocessing directive #print
  111 |         # print(st)
      |           ^~~~~
a.cc:116:3: error: invalid preprocessing directive #region
  116 | # region fastio
      |   ^~~~~~
a.cc:175:3: error: invalid preprocessing directive #endregion
  175 | # endregion
      |   ^~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import os
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'