#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 998244353
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

#define N 200005
ll m9;
ll powa[N];

ll powah(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
	a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

ll get(ll dig, ll n)
{
    ll num = (dig*((powa[n]-1+mod)%mod))%mod;
    num*=m9;
    num%=mod;
    return num;
}

void upd(ll st[],ll lazy[], ll l, ll r, ll i, ll l1, ll r1, ll val)
{
    if (lazy[i] != -1) 
    {
        st[i] = get(lazy[i],r-l+1);
  
        if (l != r) 
        { 
            lazy[i*2 + 1]   = lazy[i]; 
            lazy[i*2 + 2]   = lazy[i]; 
        } 
  
        lazy[i] = -1; 
    } 
  
    if (l>r || l>r1 || r<l1) 
        return ; 
  
    if (l>=l1 && r<=r1) 
    { 
        st[i] = get(val,r-l+1);
  
        if (l != r) 
        { 
            lazy[i*2 + 1]   = val; 
            lazy[i*2 + 2]   = val; 
        } 
        return; 
    } 
 
    ll mid = (l+r)/2; 
    upd(st,lazy, l, mid, 2*i+1, l1, r1, val); 
    upd(st,lazy, mid+1, r, 2*i+2, l1, r1, val); 
  
    ll len = r-mid;
    st[i] = ((st[2*i+1]*powa[len])%mod) + st[2*i+2];
    st[i]%=mod;
}
 
ll quer(ll st[],ll lazy[], ll l, ll r, ll i, ll l1, ll r1)
{
    if (lazy[i] != -1) 
    {
        st[i] = get(lazy[i],r-l+1);
  
        if (l != r) 
        { 
            lazy[i*2 + 1]   = lazy[i]; 
            lazy[i*2 + 2]   = lazy[i]; 
        } 
  
        lazy[i] = -1; 
    } 
  
    if (l>r || l>r1 || r<l1) 
        return 0; 
    
    if(l1<=l && r1>=r)
        return st[i];
    
    if(l == r)
        return st[i];
 
    ll mid = (l+r)/2; 
    ll p1 = quer(st,lazy, l, mid,2*i+1, l1, r1); 
    ll p2 = quer(st,lazy, mid+1, r,2*i+2, l1, r1); 
    if(r1<=mid)
        return p1;
    if(l1>mid)
        return p2;
    ll len = min(r,r1)-mid;
    ll ans = ((st[2*i+1]*powa[len])%mod) + st[2*i+2];
    ans%=mod;
    return ans;
}

int main()
{
  FAST/**/
   
   m9 = powah(9,mod-2,mod);
   
   powa[0] = 1;
   for(ll i=1;i<N;i++)
        powa[i] = powa[i-1]*10, powa[i]%=mod;
   
   ll n,q;
   cin>>n>>q;
   
   ll ht = ceil(log2(n));
   ht = (1ll<<(ht+1)) - 1;
   ll st[ht];
   memset(st,0,sizeof(st));
   ll lazy[ht];
   memset(lazy,-1,sizeof(lazy));
   
   rep(n)
        upd(st,lazy,0,n-1,0,i,i,1);
   
   rep(q)
   {
       ll l,r,d;
       cin>>l>>r>>d;
       l--,r--;
       upd(st,lazy,0,n-1,0,l,r,d);
       cout<<quer(st,lazy,0,n-1,0,0,n-1)<<'\n';
   }
   

   
   return 0;        
}  

  
          
   

Measured memory_bytes: 13636