#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 998244353;

vector<int> x0, s0;

struct SegmentTree {
    struct Lazy {
        static constexpr Lazy e() {
            return { 0 };
        }
        bool operator==(const Lazy &o) const {
            return d == o.d;
        }
        Lazy &operator*=(const Lazy &o) {
            return *this = { o.d };
        }
        int d;
    };
    struct Node {
        static constexpr Node e() {
            return { 0, 0 };
        }
        Node operator*(const Node &o) const {
            return { (int)((v + (ll)o.v * x0[w]) % P), w + o.w };
        }
        Node &act(int w, const Lazy &o) {
            return *this = { (int)((ll)s0[w] * o.d % P), this->w };
        }
        int v, w;
    };
    SegmentTree(int n) : n(n) {
        for (m = 2; m < n; m *= 2);
        t = vector<Node>(m + n + n % 2, Node::e());
        z = vector<Lazy>(m, Lazy::e());
    }
    Node &operator[](int i) {
        return t[m + i];
    }
    const Node &root() const {
        return t[1];
    }
    void build() {
        for (int i = (n - 1 + m) / 2; i > 0; i--) t[i] = t[i * 2] * t[i * 2 + 1];
    }
    void update(int i, const Node &o) {
        i += m;
        for (int j = m; j >= 2; j /= 2) propagate(i / j, j);
        for (t[i] = o; i /= 2, i > 0;) t[i] = t[i * 2] * t[i * 2 + 1];
    }
    Node query(int l, int r, int i = 1, int il = 0, int ir = -1) {
        if (ir < 0) ir = m;
        if (l <= il && ir <= r) return t[i];
        propagate(i, ir - il);
        Node o = Node::e();
        int ic = (il + ir) / 2;
        if (l < ic) o = o * query(l, r, i * 2 + 0, il, ic);
        if (ic < r) o = o * query(l, r, i * 2 + 1, ic, ir);
        return o;
    }
    void range_act(int l, int r, Lazy x, int i = 1, int il = 0, int ir = -1) {
        if (ir < 0) ir = m;
        if (l <= il && ir <= r) { act(i, ir - il, x); return; }
        propagate(i, ir - il);
        int ic = (il + ir) / 2;
        if (l < ic) range_act(l, r, x, i * 2 + 0, il, ic);
        if (ic < r) range_act(l, r, x, i * 2 + 1, ic, ir);
        t[i] = t[i * 2] * t[i * 2 + 1];
    }
    void propagate(int i, int w) {
        if (z[i] == Lazy::e()) return;
        for (int j = 0; j < 2; j++) act(i * 2 + j, w / 2, z[i]);
        z[i] = Lazy::e();
    }
    void act(int i, int w, Lazy x) {
        t[i].act(w, x);
        if (i < m) z[i] *= x;
    }
    vector<Node> t;
    vector<Lazy> z;
    int n, m;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, q;
    cin >> n >> q;

    x0 = vector<int>(n);
    s0 = vector<int>(n + 1);
    x0[0] = 1;
    for (int i = 1; i < n; i++) {
        x0[i] = (ll)x0[i - 1] * 10 % P;
    }
    s0[0] = 0;
    for (int i = 0; i < n; i++) {
        s0[i + 1] = (s0[i] + x0[i]) % P;
    }

    SegmentTree st(n);
    for (int i = 0; i < n; i++) {
        st[i] = { 1, 1 };
    }
    st.build();

    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        l = n - l;
        r = n - r;

        st.range_act(r, l, { d });

        cout << st.query(0, n).v << '\n';
    }

    return 0;
}

Measured memory_bytes: 9548