/*
    Nishant Singh
    nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 
// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********
// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// ******** Using PBDS ********
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=998244353;
ll const inf=2e18;
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
inline ll add(ll a,ll b) 
{ 
    return (a%mod + b%mod + mod)%mod; 
}
inline ll mul(ll a,ll b) 
{ 
    return (a%mod * b%mod + mod)%mod; 
}
inline ll sub(ll a,ll b) 
{ 
    return (a%mod - b%mod + mod)%mod; 
}
ll gcd(ll a,ll b)
{
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}
ll modexp(ll x, ll n){
    if(n==0){
        return 1;
    }
    else if(n&1){
        return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
    }
    else{
        return (modexp((x*x)%mod, n/2)%mod);
    }
}
ll modinv(ll n)
{
    return modexp(n,mod-2);
}
// ******** GLOBAL VARIABLES ********
ll const MAX=200002;
ll tree[4*MAX+1];
ll lazy[4*MAX+1];
ll help[10][MAX];
// ******** GLOBAL VARIABLES ********
void propagate(ll leftNode, ll rightNode, ll val){
    lazy[leftNode] = val;
    lazy[rightNode] = val;
}

void merge(ll treeNode,ll leftNode,ll rightNode,ll p){
    tree[treeNode] = add(mul(tree[leftNode], modexp(10, p)), tree[rightNode]);
}


void build(ll start, ll end, ll treeNode){
    lazy[treeNode]=0;
    if(start==end){
        tree[treeNode]=1;
        return; 
    }
    ll mid=(start+end)/2;
    ll leftNode=2*treeNode;
    ll rightNode=2*treeNode+1;
    build(start,mid,leftNode);
    build(mid + 1, end,rightNode);
    merge(treeNode, leftNode, rightNode,end - mid);
}
void update(ll start,ll end,ll left,ll right,ll val,ll treeNode){
    ll mid=(start+end)/2;
    ll leftNode=2*treeNode;
    ll rightNode=2*treeNode + 1;
    ll len=end-start + 1;
    if(lazy[treeNode]){
        if(start!=end){
            propagate(leftNode, rightNode, lazy[treeNode]);
        }
        tree[treeNode]=help[lazy[treeNode]][len];
        lazy[treeNode]=0;
    }
    if(start >= left && end <= right){
        tree[treeNode] = help[val][len];
        if(start != end){
            propagate(leftNode, rightNode, val);
        }
        return;
    }
    if(start > right || end < left){
            return;
    }
    update(start, mid, left, right, val, leftNode);
    update(mid+1, end, left, right, val, rightNode);
    merge(treeNode, leftNode, rightNode, end-mid);
}
ll query(ll start, ll end, ll left, ll right, ll treeNode){
    ll mid = (start + end);
    mid >>= 1;
    ll leftNode = 2 * treeNode;
    ll rightNode = 2 * treeNode + 1;
    ll len = (end - start + 1); 
    if(lazy[treeNode]){
        if(start != end){
            propagate(leftNode, rightNode, lazy[treeNode]);
        }
        tree[treeNode] = help[lazy[treeNode]][len];
        lazy[treeNode] = 0;
    }
    if(start >= left && end <= right){
            return tree[treeNode];
    }
    if(start > right || end < left){
            return 0;
    }
    ll leftQuery = query(start, mid, left, right, leftNode);
    ll rightQuery = query(mid + 1, end, left, right, rightNode);
    ll ret = add(mul(leftQuery, modexp(10, end - mid)), rightQuery);
    return ret;
}
void solve(){
    // lazy[i]=changes are not reflected in child  of i
    ll n,q;
    cin>>n>>q;
    init(help,0);
    build(1,n,1);
    for(ll i=1;i<=n;i++){
    	for(ll j=1;j<10;j++){
    		help[j][i]=add(mul(help[j][i-1],10),j);
    	}
    }

    while(q--){
    	ll l,r,d;
    	cin>>l>>r>>d;
    	update(1,n,l,r,d,1);
    	cout<<tree[1]<<endl;
    }
}  
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll T=1;
// cin>>T;  
    for(int t=1;t<=T;t++)
    {
// cout<<"Case #"<<t<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 27480