#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int block;
int n, q, num;
const int N = 2e5 + 7;
const ll mod = 998244353;
ll fact[N], infact[N];
ll L[N], R[N], pos[N];
ll sum[N], add[N], a[N];
ll ans = 0;
void build()
{
    block = sqrt(n);
    num = block;
    for(int i = 1; i <= num; i++)
    {
        L[i] = (i - 1) * block + 1;
        R[i] = i * block;
    }
    R[num] = n;
    for(int i = 1; i <= num; i++)
    {
        for(int j = L[i]; j <= R[i]; j++)
        {
            sum[i] += fact[j];
            sum[i] %= mod;
            pos[j] = i;
            add[j] = 0;
        }
        ans += sum[i];
        ans %= mod;
    }
}
void change(ll l, ll r, ll d)
{
    ll p = pos[l];
    ll q = pos[r];
    if(p == q)
    {
        ans -= sum[p];
        ans = (ans % mod + mod) % mod;
        if(add[p])
        {
            for(int i = L[p]; i <= R[p]; i++)
                a[i] = add[p];
            add[p] = 0;
        }
        for(int i = l; i <= r; i ++)
        {
            sum[p] -= (a[i] * fact[i]);
            sum[p] = (sum[p] % mod + mod) % mod;
            sum[p] += (d * fact[i]);
            sum[p] = (sum[p] % mod + mod) % mod;
            a[i] = d;
        }
        ans = ans + sum[p];
        ans = (ans % mod + mod) % mod;
    }
    else
    {
        ans -= sum[p];
        ans = (ans % mod + mod) % mod;
        if(add[p])
        {
            for(int i = L[p]; i <= R[p]; i++)
                a[i] = add[p];
            add[p] = 0;
        }
        for(int i = l; i <= R[p]; i ++)
        {
            sum[p] -= (a[i] * fact[i]);
            sum[p] = (sum[p] % mod + mod) % mod;
            sum[p] += (d * fact[i]);
            sum[p] = (sum[p] % mod + mod) % mod;
            a[i] = d;
        }
        ans = ans + sum[p];
        ans = (ans % mod + mod) % mod;
        for(int i = p + 1; i <= q - 1; i++)
        {
            ans -= sum[i];
            ans = (ans % mod + mod) % mod;
            sum[i] = d * (((infact[R[i]] - infact[L[i] - 1]) % mod + mod) % mod);
            sum[i] = (sum[i] % mod + mod % mod);
            ans += sum[i];
            add[i] = d;
            ans = (ans % mod + mod) % mod;
        }

        ans -= sum[q];
        ans = (ans % mod + mod) % mod;
        if(add[q])
        {
            for(int i = L[q]; i <= R[q]; i++)
                a[i] = add[q];
            add[q] = 0;
        }
        for(int i = L[q]; i <= r; i ++)
        {
            sum[q] -= (a[i] * fact[i]);
            sum[q] = (sum[q] % mod + mod) % mod;
            sum[q] += (d * fact[i]);
            sum[q] = (sum[q] % mod + mod) % mod;
            a[i] = d;
        }
        ans = ans + sum[q];
        ans = (ans % mod + mod) % mod;
    }
}
int main()
{
    memset(add, 0, sizeof add);
    scanf("%d %d", &n, &q);
    for(int i = 1; i <= n; i++)
        a[i] = 1;
    fact[n] = 1;
    for(int i = n - 1; i >= 1; i--)
        fact[i] = fact[i + 1] * 10ll % mod;
    for(int i = 1; i <= n; i++)
    {
        infact[i] = infact[i - 1] % mod;
        infact[i] = ((infact[i] + fact[i]) % mod + mod) % mod;
    }
    build();
    while(q--)
    {
        ll l, r, d;
        scanf("%lld %lld %lld,", &l, &r, &d);
        change(l, r, d);
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 11624