// This code wrote by chtholly_micromaker(MicroMaker)
#pragma GCC optimize("Ofast,O3,inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#define reg register
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof x)
#define sz(x) (int)(x).size()
#define ln puts("")
#define lsp putchar(32)
#define pb push_back
#define MP make_pair
#define dbg(x) cerr<<">"<<__func__<<"\tLine: "<<__LINE__<<' '<<#x<<": "<<x<<endl
using namespace std;
const int MaxN=200050;
const int p=998244353;
template <class t> inline void read(t &s){s=0;
reg int f=1;reg char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c))s=(s<<3)+(s<<1)+(c^48),c=getchar();s*=f;return;}
template<class t,class ...A> inline void read(t &x,A &...a){read(x);read(a...);}
template <class t> inline void write(t x){if(x<0)putchar('-'),x=-x;
int buf[21],top=0;while(x)buf[++top]=x%10,x/=10;if(!top)buf[++top]=0;
while(top)putchar(buf[top--]^'0');return;}
inline void setIn(string s){freopen(s.c_str(),"r",stdin);return;}
inline void setOut(string s){freopen(s.c_str(),"w",stdout);return;}
inline void setIO(string s=""){setIn(s+".in");setOut(s+".out");return;}
template <class t>inline bool checkmin(t&x,t y){if(x>y){x=y;return 1;}return 0;}
template <class t>inline bool checkmax(t&x,t y){if(x<y){x=y;return 1;}return 0;}
inline int lowbit(int x){return x&(-x);}
int a[MaxN<<2],lazy[MaxN<<2];
int f[10][MaxN];
int p10[MaxN];
#define lson (u<<1)
#define rson (u<<1|1)
inline int fastpow(int a,int b)
{
	reg int res=1;
	for(;b;b>>=1,a=a*a%p)
		if(b&1)
			res=res*a%p;
	return res;
}
inline void pushup(int u,int l,int r)
{
	reg int mid=(l+r)>>1;
	(a[u]=a[lson]*p10[r-mid]%p+a[rson])%=p;
	return;
}
inline void pushdown(int u,int l,int r)
{
	if(lazy[u])
	{
		reg int mid=(l+r)>>1;
		lazy[lson]=lazy[rson]=lazy[u];
		a[lson]=f[lazy[u]][mid-l+1];
		a[rson]=f[lazy[u]][r-mid];
		lazy[u]=0;
	}
	return;
}
inline void buildtr(int u,int l,int r)
{
	if(l==r)
	{
		a[u]=1;
		return;
	}
	reg int mid=(l+r)>>1;
	buildtr(lson,l,mid);
	buildtr(rson,mid+1,r);
	pushup(u,l,r);
	return;
}
inline void modify(int u,int l,int r,int ql,int qr,int k)
{
	if(ql<=l&&r<=qr)
	{
		a[u]=f[k][r-l+1],lazy[u]=k;
		return;
	}
	pushdown(u,l,r);
	reg int mid=(l+r)>>1;
	if(ql<=mid)
		modify(lson,l,mid,ql,qr,k);
	if(mid<qr)
		modify(rson,mid+1,r,ql,qr,k);
	pushup(u,l,r);
	return;
}
int n;
int ans;
inline int query(int u,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr)
		return a[u];
	pushdown(u,l,r);
	reg int mid=(l+r)>>1;
	if(ql>mid)
		return query(rson,mid+1,r,ql,qr);
	if(mid>=qr)
		return query(lson,l,mid,ql,qr);
	return (query(lson,l,mid,ql,qr)*p10[min(qr,r)-mid]%p+query(rson,mid+1,r,ql,qr))%p;
}
signed main(void)
{
	int q;read(n,q);
	p10[0]=1;
	for(int i=1;i<=n;++i)
	{
		p10[i]=p10[i-1]*10%p;
		for(int j=1;j<=9;++j)
			f[j][i]=(f[j][i-1]*10%p+j)%p;
	}
	reg int l,r,k;
	buildtr(1,1,n);
	ans=a[1];
	while(q--)
	{
		read(l,r,k);
		reg int t=query(1,1,n,l,r);
		(t*=p10[n-r])%=p;
		(ans-=t-p)%=p;
		(ans+=f[k][r-l+1]*p10[n-r]%p)%=p;
		modify(1,1,n,l,r,k);
		write(ans),ln;
	}
	return 0;
}

/*
 * Check List:
 * 1. Input / Output File (USACO and OI and UVa)
 * 2. long long 
 * 3. Special Test such as n=1
 * 4. Array Size
 * 5. Memory Limit (OI) int is 4 and longlong is 8
 * 6. Mod (a*b%p*c%p not a*b*c%p  ,  (a-b+p)%p not a-b )
 * 7. Name ( int k; for(int k...))
 * 8. more tests , (T=2 .. more)
 * 9. blank \n after a case
*/






Measured memory_bytes: 27472