#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

namespace my
{
	//-----------------------------------------------------------------------------
	inline char cn()
	{
		static char buf[1000010],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
	}
	#define cn getchar
	template<class TY>void read(TY &x)
	{
		x=0;int f1=1;char ch=cn();
		while(ch<'0'||ch>'9'){if(ch=='-')f1=-1;ch=cn();}
		while(ch>='0'&&ch<='9')x=x*10+(ch-'0'),ch=cn(); x*=f1;
	}
	char Output[1000100],Zk[100];int op_top=0,Zk_top;
	void fcheck(int Type=0){if(Type||op_top>=1000000)fwrite(Output,1,op_top,stdout),op_top=0;}
	template<class TY>inline void write(TY x)
	{
		if(x==0){Output[op_top++]='0';fcheck();return;}
		if(x<0)Output[op_top++]='-',x=-x;
		Zk_top=0;while(x)Zk[++Zk_top]=x%10+'0',x/=10;
		while(Zk_top)Output[op_top++]=Zk[Zk_top--];fcheck();
	}
	#define K_G Output[op_top++]=' '
	#define H_C Output[op_top++]='\n'
	//--------------------------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------------------------
	#define ll long long
	#define uint unsigned int
	#define ull unsigned long long
	#define db double
	#define pb push_back
	#define INV(x) ksm(x,mod-2)
	#define inf 999999999
	#define mod 998244353
	
	template<class TY>void add(TY &x,TY y){x=(x+y>=mod?x+y-mod:x+y);}
	template<class TY>void dec(TY &x,TY y){x=(x-y<0?x-y+mod:x-y);}
	template<class TY>TY add(TY x){return x>=mod?x-mod:x;}
	template<class TY>TY dec(TY x){return x<0?x+mod:x;}
	template<class TY>void chkmin(TY &x,TY y){if(y<x)x=y;}
	template<class TY>void chkmax(TY &x,TY y){if(y>x)x=y;}
	//
	int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}
	template<class TY>void discretization(TY *arr,int St,int Ed){
		vector<TY>Arr;Arr.clear();
		for(int i=St;i<=Ed;i++)Arr.push_back(arr[i]);
		sort(Arr.begin(),Arr.end());
		for(int i=St;i<=Ed;i++)arr[i]=lower_bound(Arr.begin(),Arr.end(),arr[i])-Arr.begin()+1;
	}
	//-----------------------------------------------------------------------------------------------
	
	//----------------------------------------------------------------------------------------------- 
	#define maxn 200010
	#define mod 998244353
	int n,m,a[maxn];
	struct node{
		int l,r,mid,val,z,lazy;node *zuo,*you;
		node(int x,int y):l(x),r(y),mid(l+r>>1),z(0),lazy(0){
			if(x<y){
				zuo=new node(x,mid);
				you=new node(mid+1,y);
				z=val=add(zuo->val+you->val);
			}else zuo=you=NULL,z=val=a[l];
		}
		void update(int x){z=1ll*val*x%mod;lazy=x;}
		void pushdown(){
			if(lazy){
				if(zuo)zuo->update(lazy);
				if(you)you->update(lazy);
				lazy=0;
			}
		}
		void change(int x,int y,int c){
			pushdown();
			if(l==x&&r==y)return update(c);
			if(y<=mid)zuo->change(x,y,c);
			else if(x>=mid+1)you->change(x,y,c);
			else zuo->change(x,mid,c),you->change(mid+1,y,c);
			z=add(zuo->z+you->z);
		}
	}*root;
	
	void main()
	{
		read(n);read(m);
		a[n]=1;for(int i=n-1;i>=1;i--)a[i]=10ll*a[i+1]%mod;
		root=new node(1,n);
		for(int i=1,x,y,z;i<=m;i++){
			read(x);read(y);read(z);
			root->change(x,y,z);
			write(root->z);H_C;
		}
		fcheck(1);return;
	}
}

int main(){my::main();return 0;}

Measured memory_bytes: 23504