Language: C++

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nq[0];
        ModInt[] pow10 = new ModInt[n + 1];
        pow10[0] = 1;
        for (int i = 1; i < pow10.Length; i++)
            pow10[i] = pow10[i - 1] * 10;

        SegmentTree<Node, int> node = new SegmentTree<Node, int>(
            Enumerable.Range(1, n).Select(x => new Node() { Length = 1, Digits = pow10[n - x], Sum = 1 * pow10[n - x] }).ToArray(),
            new Node() { Digits = 0, Sum = 0, Length = 0 },
            0,
            (x, y) => new Node() { Digits = x.Digits + y.Digits, Length = x.Length + y.Length, Sum = x.Sum + y.Sum },
            (x, y) => y == 0 ? x : y,
            (x, y) => y == 0 ? x : new Node() { Digits = x.Digits, Sum = x.Digits * y, Length = x.Length }
        );
        //Console.WriteLine(node.Query(0, node.Size - 1).Sum);
        for (int i = 0; i < nq[1]; i++)
        {
            var lrd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var l = lrd[0] - 1;
            var r = lrd[1] - 1;
            var d = lrd[2];
            node.Update(l, r, d);
            Console.WriteLine(node.Query(0, node.Size - 1).Sum);
        }
    }
}

struct Node
{
    public int Length;
    public ModInt Digits;
    public ModInt Sum;
}


struct ModInt
{
    public const int Mod = 998244353;
    const long POSITIVIZER = ((long)Mod) << 31;
    long Data;
    public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }
    public static implicit operator long(ModInt modInt) => modInt.Data;
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
    public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
    public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
    public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
    public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
    public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
    public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
    public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
    public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
    public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data;
    public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data;
    public override string ToString() => Data.ToString();
    public override bool Equals(object obj) => (ModInt)obj == this;
    public override int GetHashCode() => (int)Data;
    static long GetInverse(long a)
    {
        long div, p = Mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
        while (true)
        {
            if (p == 1) return x2 + Mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;
            if (a == 1) return x1 + Mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;
        }
    }
}


class SegmentTree<DataT, OperatorT>
{
    public readonly int Size;
    DataT DataIdentity;
    OperatorT OperatorIdentity;
    Func<DataT, DataT, DataT> MergeData;
    Func<OperatorT, OperatorT, OperatorT> MergeOperator;
    Func<DataT, OperatorT, DataT> Operate;
    int LeafCount;
    int Height;
    DataT[] Data;
    OperatorT[] Operators;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(int size, DataT dataIdentity, OperatorT operatorIdentity, Func<DataT, DataT, DataT> mergeData, Func<OperatorT, OperatorT, OperatorT> mergeOpeator, Func<DataT, OperatorT, DataT> operate)
        : this(dataIdentity, operatorIdentity, mergeData, mergeOpeator, operate)
    {
        Size = size;
        Build();
        for (int i = 0; i < Data.Length; i++) Data[i] = DataIdentity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(DataT[] data, DataT dataIdentity, OperatorT operatorIdentity, Func<DataT, DataT, DataT> mergeData, Func<OperatorT, OperatorT, OperatorT> mergeOpeator, Func<DataT, OperatorT, DataT> operate)
        : this(dataIdentity, operatorIdentity, mergeData, mergeOpeator, operate)
    {
        Size = data.Length;
        Build();
        for (int i = 0; i < data.Length; i++) Data[i + LeafCount] = data[i];
        for (int i = data.Length + LeafCount; i < Data.Length; i++) Data[i] = dataIdentity;
        for (int i = LeafCount - 1; i >= 0; i--) Data[i] = MergeData(Data[i << 1], Data[(i << 1) + 1]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private SegmentTree(DataT dataIdentity, OperatorT operatorIdentity, Func<DataT, DataT, DataT> mergeData, Func<OperatorT, OperatorT, OperatorT> mergeOpeator, Func<DataT, OperatorT, DataT> operate)
    {
        DataIdentity = dataIdentity;
        OperatorIdentity = operatorIdentity;
        MergeData = mergeData;
        MergeOperator = mergeOpeator;
        Operate = operate;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Build()
    {
        Height = 1;
        LeafCount = 1;
        while (LeafCount < Size) { Height++; LeafCount <<= 1; }
        Operators = new OperatorT[LeafCount << 1];
        for (int i = 0; i < Operators.Length; i++) Operators[i] = OperatorIdentity;
        Data = new DataT[LeafCount << 1];
    }
    public DataT this[int index]
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get { Propagate(index + LeafCount); return Reflect(index); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        set { Propagate(index += LeafCount); Data[index] = value; Operators[index] = OperatorIdentity; Calculate(index, index); }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Update(int l, int r, OperatorT x)
    {
        l += LeafCount;
        r += LeafCount;
        int origL = l, origR = r;
        Propagate(l, r);
        while (l <= r)
        {
            if ((l & 1) == 1) Operators[l] = MergeOperator(Operators[l], x);
            if ((r & 1) == 0) Operators[r] = MergeOperator(Operators[r], x);
            l = (l + 1) >> 1; r = (r - 1) >> 1;
        }
        Calculate(origL, origR);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public DataT Query(int l, int r)
    {
        l += LeafCount;
        r += LeafCount;
        DataT lRes = DataIdentity, rRes = DataIdentity;
        Propagate(l, r);
        while (l <= r)
        {
            if ((l & 1) == 1) lRes = MergeData(lRes, Reflect(l));
            if ((r & 1) == 0) rRes = MergeData(Reflect(r), rRes);
            l = (l + 1) >> 1; r = (r - 1) >> 1;
        }
        return MergeData(lRes, rRes);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Propagate(int ind) { for (int i = Height - 1; i >= 1; i--) { Eval(ind >> i); } return; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Propagate(int l, int r)
    {
        if (l == r) { Propagate(l); return; }
        int xor = l ^ r, i = Height - 1;
        for (; (xor >> i) == 0; i--) { Eval(l >> i); }
        for (; i >= 1; i--) { Eval(l >> i); Eval(r >> i); }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private DataT Reflect(int ind) { return Operate(Data[ind], Operators[ind]); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Eval(int ind)
    {
        int l = ind << 1, r = ind << 1 | 1;
        Operators[l] = MergeOperator(Operators[l], Operators[ind]);
        Operators[r] = MergeOperator(Operators[r], Operators[ind]);
        Data[ind] = Reflect(ind);
        Operators[ind] = OperatorIdentity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Calculate(int l, int r)
    {
        var xor = l ^ r;
        while (xor > 1) { xor >>= 1; l >>= 1; r >>= 1; Data[l] = MergeData(Reflect(l << 1), Reflect((l << 1) | 1)); Data[r] = MergeData(Reflect(r << 1), Reflect((r << 1) | 1)); }
        while (l > 1) { l >>= 1; Data[l] = MergeData(Reflect(l << 1), Reflect((l << 1) | 1)); }
    }
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Diagnostics;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.IO;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'System'
    6 | using System.Linq;
      |       ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'System'
    7 | using System.Numerics;
      |       ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'System'
    8 | using System.Text;
      |       ^~~~~~
a.cc:9:7: error: expected nested-name-specifier before 'System'
    9 | using System.Text.RegularExpressions;
      |       ^~~~~~
a.cc:10:7: error: expected nested-name-specifier before 'System'
   10 | using System.Threading.Tasks;
      |       ^~~~~~
a.cc:11:7: error: expected nested-name-specifier before 'static'
   11 | using static System.Math;
      |       ^~~~~~
a.cc:12:29: error: 'System' does not name a type
   12 | using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
      |                             ^~~~~~
a.cc:13:27: error: 'System' does not name a type
   13 | using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
      |                           ^~~~~~
a.cc:15:1: error: expected unqualified-id before 'public'
   15 | public static class P
      | ^~~~~~
a.cc:49:11: error: expected ':' before 'int'
   49 |     public int Length;
      |           ^~~~
      |           :
a.cc:50:11: error: expected ':' before 'ModInt'
   50 |     public ModInt Digits;
      |           ^~~~~~~
      |           :
a.cc:50:12: error: 'ModInt' does not name a type
   50 |     public ModInt Digits;
      |            ^~~~~~
a.cc:51:11: error: expected ':' before 'ModInt'
   51 |     public ModInt Sum;
      |           ^~~~~~~
      |           :
a.cc:51:12: error: 'ModInt' does not name a type
   51 |     public ModInt Sum;
      |            ^~~~~~
a.cc:52:2: error: expected ';' after struct definition
   52 | }
      |  ^
      |  ;
a.cc:57:11: error: expected ':' before 'const'
   57 |     public const int Mod = 998244353;
      |           ^~~~~~
      |           :
a.cc:60:11: error: expected ':' before 'ModInt'
   60 |     public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }
      |           ^~~~~~~
      |           :
a.cc:61:11: error: expected ':' before 'static'
   61 |     public static implicit operator long(ModInt modInt) => modInt.Data;
      |           ^~~~~~~
      |           :
a.cc:61:19: error: 'implicit' does not name a type; did you mean 'explicit'?
   61 |     public static implicit operator long(ModInt modInt) => modInt.Data;
      |                   ^~~~~~~~
      |                   explicit
a.cc:62:11: error: expected ':' before 'static'
   62 |     public static implicit operator ModInt(long val) => new ModInt(val);
      |           ^~~~~~~
      |           :
a.cc:62:19: error: 'implicit' does not name a type; did you mean 'explicit'?
   62 |     public static implicit operator ModInt(long val) => new ModInt(val);
      |                   ^~~~~~~~
      |                   explicit
a.cc:63:11: error: expected ':' before 'static'
   63 |     public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
      |           ^~~~~~~
      |           :
a.cc:63:57: error: invalid pure specifier (only '= 0' is allowed) before 'new'
   63 |     public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
      |                                                         ^~~
a.cc:63:26: error: 'static ModInt ModInt::operator+(ModInt, int)' must be either a non-static member function or a non-member function
   63 |     public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
      |                          ^~~~~~~~
a.cc:64:11: error: expected ':' before 'static'
   64 |     public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
      |           ^~~~~~~
      |           :
a.cc:64:58: error: invalid pure specifier (only '= 0' is allowed) before 'new'
   64 |     public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
      |                                                          ^~~
a.cc:64:26: error: 'static ModInt ModInt::operator+(ModInt, long int)' must be either a non-static member function or a non-member function
   64 |     public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
      |                          ^~~~~~~~
a.cc:65:11: error: expected ':' before 'static'
   65 |     public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
      |           ^~~~~~~
      |           :
a.cc:65:26: error: 'static ModInt ModInt::operator+(ModInt, ModInt)' must be either a non-static member function or a non-member function
   65 |     public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
      |                          ^~~~~~~~
a.cc:66:11: error: expected ':' before 'static'
   66 |     public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
      |           ^~~~~~~
      |           :
a.cc:66:57: error: invalid pure specifier (only '= 0' is allowed) before 'new'
   66 |     public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
      |                                                         ^~~
a.cc:66:26: error: 'static ModInt ModInt::operator-(ModInt, int)' must be either a non-static member function or a non-member function
   66 |     public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
      |                          ^~~~~~~~
a.cc:67:11: error: expected ':' before 'static'
   67 |     public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
      |           ^~~~~~~
      |           :
a.cc:67:58: error: invalid pure specifier (only '= 0' is allowed) before 'new'
   67 |     public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
      |                                                          ^~~
a.cc:67:26: error: 'static ModInt ModInt::operator-(ModInt, long int)' must be either a non-static member function or a non-member function
   67 |     public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
      |                          ^~~~~~~~
a.cc:68:11: error: expected ':' before 'static'
   68 |     public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
      |           ^~~~~~~
      |           :
a.cc:68:26: error: 'static ModInt ModInt::operator-(ModInt, ModInt)' must be either a non-static member function or a non-member function
   68 |     public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
      |                          ^~~~~~~~
a.cc:69:11: error: expected ':' before 'static'
   69 |     public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
      |           ^~~~~~~
      |           :
a.cc:69:57: error: invalid pure specifier (only '= 0' is allowed) before 'new'
   69 |     public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
      |                                                         ^~~
a.cc:69:26: error: 'static ModInt ModInt::operator*(ModInt, int)' must be either a non-static member function or a non-member function
   69 |     public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
      |                          ^~~~~~~~
a.cc:70:11: error: expected ':' before 'static'
   70 |     public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
      |           ^~~~~~~
      |           :
a.cc:70:58: error: invalid pure specifier (only '= 0' is allowed) before 'a'
   70 |     public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
      |                                                          ^
a.cc:70:26: error: 'static ModInt ModInt::operator*(ModInt, long int)' must be either a non-static member function or a non-member function
   70 |     public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
      |                          ^~~~~~~~
a.cc:71:11: error: expected ':' before 'static'
   71 |     public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
      |           ^~~~~~~
      |           :
a.cc:71:60: error: invalid pure specifier (only '= 0' is allowed) before 'new'
   71 |     public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
      |                                                            ^~~
a.cc:71:26: error: 'static ModInt ModInt::operator*(ModInt, ModInt)' must be either a non-static member function or a non-member function
   71 |     public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
      |                          ^~~~~~~~
a.cc:72:11: error: expected ':' before 'static'
   72 |     public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
      |           ^~~~~~~
      |           :
a.cc:72:60: error: invalid pure specifier (only '= 0' is allowed) before 'new'
   72 |     public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
      |