#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001

struct segtree{
    int siz=1;
    vector<ll> nodes;
    vector<ll> power;
    vector<ll> pref,op;
    int len;
    segtree(ll n){
        while(siz<n){
            siz*=2;
        }
        len=n;
        nodes.assign(2*siz,0);
        op.assign(2*siz,-1);
        power.resize(n);
        pref.resize(n);
        power[0]=1;
        pref[0]=1;
        for(int i=1 ; i<n ; i++){
            power[i]=power[i-1]*10;
            pref[i]=pref[i-1]+power[i];
            pref[i]%=mod;
            power[i]%=mod;
        }
        build(0,0,siz-1);
    }
    
    void build(int x,int lx,int rx){
        if(rx==lx){
            if(lx<len){
                nodes[x]=power[len-1-lx];
            }
            return;
        }
        int mid=(lx+rx)/2;
        build(2*x+1,lx,mid);
        build(2*x+2,mid+1,rx);
        nodes[x]=nodes[2*x+1]+nodes[2*x+2];
        nodes[x]%=mod;
    }
    
    void propagate(int x,int lx,int rx){
        if(op[x]==-1 || lx==rx){
            return;
        }
        op[2*x+1]=op[x];
        op[2*x+2]=op[x];
        int mid=(lx+rx)/2;
        if(mid==(len-1)){
            nodes[2*x+1]=(op[x]*pref[len-lx-1]);
            nodes[2*x+1]%=mod;
        }else{
            if(pref[len-lx-1]>=pref[len-mid-2]){
                nodes[2*x+1]=(op[x]*(-pref[len-mid-2]+pref[len-lx-1]));
                nodes[2*x+1]%=mod;
            }else{
                nodes[2*x+1]=(op[x]*(-pref[len-mid-2]+pref[len-lx-1]+mod));
                nodes[2*x+1]%=mod;
            }
        }
        if(rx==(len-1)){
            nodes[2*x+2]=(op[x]*pref[len-mid-2]);
            nodes[2*x+2]%=mod;
        }else{
            if(pref[len-mid-2]>=pref[len-rx-2]){
                nodes[2*x+2]=(op[x]*(-pref[len-rx-2]+pref[len-mid-2]));
                nodes[2*x+2]%=mod;
            }else{
                nodes[2*x+2]=(op[x]*(-pref[len-rx-2]+pref[len-mid-2]+mod));
                nodes[2*x+2]%=mod;
            }
        }
        op[x]=-1;
    }
    
    void set(int l,int r,ll v,int x,int lx,int rx){
        propagate(x,lx,rx);
        if(l>rx || lx>r){
            return;
        }else if(lx>=l && rx<=r){
            op[x]=v;
            if(rx==(len-1)){
                nodes[x]=(v*pref[len-lx-1]);
                nodes[x]%=mod;
            }else{
                if(pref[len-lx-1]>=pref[len-rx-2]){
                    // if(l==2 && v==2){
                    //     cout << ((-pref[len-rx-2]+pref[len-lx-1])) << endl;
                    // }
                    nodes[x]=(v*(-pref[len-rx-2]+pref[len-lx-1]));
                    nodes[x]%=mod;
                }else{
                    // if(l==2 && v==2){
                    //     cout << ((-pref[len-rx-2]+pref[len-lx-1]+mod)) << endl;
                    // }
                    nodes[x]=(v*(-pref[len-rx-2]+pref[len-lx-1]+mod));
                    nodes[x]%=mod;
                }
            }
            propagate(x,lx,rx);
            return;
        }
        int mid=(lx+rx)/2;
        set(l,r,v,2*x+1,lx,mid);
        set(l,r,v,2*x+2,mid+1,rx);
        nodes[x]=nodes[2*x+1]+nodes[2*x+2];
        nodes[x]%=mod;
    }
    
    void set(int l,int r,ll v){
        set(l,r,v,0,0,siz-1);
    }
};

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int n,q;
	    cin >> n >> q;
	    segtree st(n);
	    while(q--){
	        int l,r;
	        ll d;
	        cin >> l >> r >> d;
	        l--;
	        r--;
	        st.set(l,r,d);
	        cout << st.nodes[0] << endl;
	    }
	}
	return 0;
}

Measured memory_bytes: 14568