#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
const Int MOD = 998244353;
Int TEN[200020], DIGIT[10][200020];
struct Value {
    Int S, size;
    Value() : S(1), size(1) {}
    Value(Int s_, Int size_) : S(s_ % MOD), size(size_) {}
};
const Value ZERO(0, 0);
Value combine(Value a, Value b) {
    if (a.size == 0) return b;
    if (b.size == 0) return a;
    return Value(a.S * TEN[b.size] + b.S, a.size + b.size);
}
struct ReplaceDigits {
    int N;
    vector<Int> A;
    vector<Value> X;
    ReplaceDigits(int n) {
        N = 1; while (N < n) N *= 2;
        A.resize(2 * N, -1), X.resize(2 * N);
        for (int i = N - 1; i > 0; i--) X[i] = combine(X[2*i+0], X[2*i+1]);
    }
    void replace_0(int L, int R, int D, int node, int nodeL, int nodeR) {
        if (L <= nodeL && nodeR <= R) {
            A[node] = D;
            X[node] = Value(DIGIT[D][nodeR - nodeL], nodeR - nodeL);
        } else if (nodeR <= L || R <= nodeL) {
            return;
        } else {
            if (A[node] != -1) {
                A[2*node+0] = A[2*node+1] = A[node];
                X[2*node+0] = Value(DIGIT[A[node]][(nodeR - nodeL)/2], (nodeR - nodeL)/2);
                X[2*node+1] = Value(DIGIT[A[node]][(nodeR - nodeL)/2], (nodeR - nodeL)/2);
                A[node] = -1;
            }
            replace_0(L, R, D, 2*node+0, nodeL, (nodeL + nodeR) / 2);
            replace_0(L, R, D, 2*node+1, (nodeL + nodeR) / 2, nodeR);
            X[node] = combine(X[2*node+0], X[2*node+1]);
        }
    }
    void replace(int L, int R, int D) {
        replace_0(L, R, D, 1, 0, N);
    }
    Value get_0(int L, int R, int node, int nodeL, int nodeR) {
        if (L <= nodeL && nodeR <= R) {
            if (A[node] != -1) {
                X[node] = Value(DIGIT[A[node]][nodeR - nodeL], nodeR - nodeL);
            }
            return X[node];
        } else if (nodeR <= L || R <= nodeL) {
            return ZERO;
        } else {
            if (A[node] != -1) {
                A[2*node+0] = A[2*node+1] = A[node];
                X[2*node+0] = Value(DIGIT[A[node]][(nodeR - nodeL)/2], (nodeR - nodeL)/2);
                X[2*node+1] = Value(DIGIT[A[node]][(nodeR - nodeL)/2], (nodeR - nodeL)/2);
                A[node] = -1;
            }
            Value x = get_0(L, R, 2*node+0, nodeL, (nodeL + nodeR) / 2);
            Value y = get_0(L, R, 2*node+1, (nodeL + nodeR) / 2, nodeR);
            X[node] = combine(X[2*node+0], X[2*node+1]);
            return combine(x, y);
        }
    }
    Value get(int L, int R) {
        return get_0(L, R, 1, 0, N);
    }
};
int main() {
    TEN[0] = 1; TEN[1] = 10;
    for (int d = 0; d <= 9; d++) DIGIT[d][1] = d;
    for (int i = 2; i <= 200000; i++) {
        TEN[i] = TEN[i - 1] * 10 % MOD;
        for (int d = 0; d <= 9; d++) DIGIT[d][i] = (DIGIT[d][i - 1] * 10 + d) % MOD;
    }
    int N, Q; cin >> N >> Q;
    ReplaceDigits rd(N);
    for (int i = 0; i < Q; i++) {
        int l, r, d; cin >> l >> r >> d; l--;
        rd.replace(l, r, d);
        cout << rd.get(0, N).S << '\n';
    }
    return 0;
}

Measured memory_bytes: 32784