#include<bits/stdc++.h>
using namespace std;

#define         ld                  long double
#define         lli                 long long int
#define         vi                  vector<int>
#define         vlli                vector<lli>
#define         vvi                 vector<vi >
#define         vvl                 vector<vlli >
#define         str                 string
#define         vs                  vector<str>
#define         vb                  vector<bool>
#define         mp                  make_pair
#define         pii                 pair<int, int>
#define         pll                 pair<lli, lli>
#define         vpii                vector<pii>
#define         vpll                vector<pll>
#define         pb                  push_back
#define         all(a)              a.begin(),a.end()
#define         rev(a)              reverse(all(a))
#define         min3(a, b, c)       min(a, min(b, c))
#define         max3(a, b, c)       max(a, max(b, c))
#define         ft                  first
#define         sd                  second

#define         loop(i, s, l, j)    for(int i = s; i < l; i += j)
#define         rloop(i, s, l, j)   for(int i = s; i >= l; i -= j)
#define         rep(i, n)           loop(i,0,n,1)
#define         rrep(i, n)          rloop(i,n-1,0,1) 

#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define mod 998244353
#define inf 10000000
#define limit 200001

int n, q;
str s;
lli tree[4*limit], p10[limit], sp10[limit];
vlli lazy(4*limit, -1);

void build(int node, int start, int end)
{
    if(start == end)
    {
        tree[node] = 1;
        return;
    }

    int left = (node<<1);
    int right = (left|1);
    int m = (start+end)>>1;

    build(left, start, m);
    build(right, m+1, end);

    tree[node] = ((tree[left] * p10[end-m])%mod + tree[right])%mod;

}

void update(int node, int start, int end, int l, int r, int d)
{
    int left = (node<<1);
    int right = (left|1);
    int m = (start+end)>>1;

    if(lazy[node] != -1)
    {
        tree[node] = (sp10[end-start] * lazy[node])%mod;
        if(start != end)
            lazy[left] = lazy[right] = lazy[node];
        lazy[node] = -1;
    }

    if(start > end || start > r || l > end)
        return;

    if(start >= l && end <= r)
    {
        tree[node] = (sp10[end-start] * d)%mod;
        if(start != end)
            lazy[left] = lazy[right] = d;
        return;
    }
    update(left, start, m, l, r, d);
    update(right, m+1, end, l, r, d);    
    tree[node] = ((tree[left] * p10[end-m])%mod + tree[right])%mod;
}

pll query(int node, int start, int end, int l, int r)
{
    //no intersection
    if(start > end || start > r || l > end)
        return mp(0ll, 0ll);

    int left = (node<<1);
    int right = (left|1);
    int m = (start+end)>>1;

    //apply lazy
    if(lazy[node] != -1)
    {
        tree[node] = (sp10[end-start] * lazy[node])%mod;
        if(start != end)
            lazy[left] = lazy[right] = lazy[node];
        lazy[node] = -1;
    }

    //complete
    if(start >= l && end <= r)
        return mp(tree[node], (lli)end-start+1);

    //partial
    pll lval = query(left, start, m, l, r);
    pll rval = query(right, m+1, end, l, r);

    lli res = ((lval.ft * p10[rval.sd])%mod + rval.ft)%mod;
    lli len = lval.ft + rval.sd;
    return mp(res, len);
}

void solve(int test_case)
{
    p10[0] = 1;
    sp10[0] = 1;
    loop(i,1,limit,1)
    {
        p10[i] = (p10[i-1] * 10)%mod;
        sp10[i] = (sp10[i-1] + p10[i])%mod;
    }

    int n, q;
    cin >> n >> q;
    s = "";
    rep(i,n)
        s += "1";

    build(1,0,n-1);
    rep(i,q)
    {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;

        update(1,0,n-1,l,r,d);
        cout << query(1,0,n-1,0,n-1).ft << '\n';
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    fastio();
    int q = 1;
    //cin >> q;
    rep(i,q)
        solve(i+1);
}


Measured memory_bytes: 16944