using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Globalization;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var st=new Lst(s[0]);
		st.Add(0,s[0]-1,1);
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<s[1];i++) {
			var e=sc.Ia;
			st.Add(e[0]-1,e[1]-1,e[2]);
			sb.Append(st.Get(0,s[0]-1).d1+"\n");
		}
		Console.Write(sb);
	}
}
public class Lst{
	public struct Dt{
		public long d1,lz1;
		public Dt(bool b){d1=0;lz1=0;}
		public Dt(long d1){
			this.d1=d1;
			lz1=0;
		}
		public Dt(Dt e){d1=e.d1;lz1=e.lz1;}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Dt Um(Dt a,long n1,int h){
			a.d1=g[n1][h];
			return a;
		}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Dt Lm(Dt a,long n1){
			a.lz1=n1;
			return a;
		}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Dt Cm(Dt l,Dt r,int h){
			var a=new Dt(true);
			a.d1=(l.d1*g[0][h+1]+r.d1)%mod;
			return a;
		}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Dt Cl(Dt a){
			a.lz1=0;
			return a;
		}
		public override string ToString(){
			var me=GetType().GetFields(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance);
			var st="";
			foreach (MemberInfo e in me){st+=e.Name+":"+GetType().GetField(e.Name).GetValue(this)+" ";}
			return st;
		}
	}
	const int mod=998244353;
	private Dt[] dat;
	private int[] ha;
	private static long[][] g;
	private bool[] bo;
	private int n,m=1,cnt;
	private readonly Dt ie=new Dt(true);
	public Lst(int n){
		this.n=n;
		while(m<n){m<<=1;}
		cnt=m+n;
		dat=new Dt[cnt];
		bo=new bool[cnt];
		ha=new int[cnt];
		for(int i = 0;i<cnt;i++) {dat[i]=ie;}
		for(int i = cnt-n;i<cnt;i++) {
			ha[i]=1;
			ha[i>>1]++;
		}
		for(int i = cnt-n-1;i>1;i--) {ha[i>>1]+=ha[i];}
		g=new long[10][];
		for(int i = 0;i<10;i++) {
			g[i]=new long[n+1];
			g[i][1]=Max(i,1);
			for(int j = 2;j<=n;j++) {
				g[i][j]=(g[i][j-1]*10+i)%mod;
			}
		}
	}
	public Lst(int[] a){
		n=a.Length;
		while(m<n){m<<=1;}
		cnt=m+n;
		dat=new Dt[cnt];
		bo=new bool[cnt];
		ha=new int[cnt];
		for(int i = cnt-n;i<cnt;i++) {
			dat[i]=new Dt(a[i-cnt+n]);
			ha[i]=1;
		}
		for(int i = cnt-n-1;i>0;i--) {
			if(i<<1<cnt){
				dat[i]=Dt.Cm(dat[i<<1],(i<<1)+1<cnt?dat[(i<<1)+1]:ie,(i<<1)+1<cnt?ha[(i<<1)+1]:0);
				ha[i]=ha[i<<1]+((i<<1)+1<cnt?ha[(i<<1)+1]:0);
			}
			else{dat[i]=ie;}
		}
	}
	public Dt Get(int a,int b){return Fge(a,b,1,0,n-1);}
	private Dt Fge(int a,int b,int k,int l,int r){
		if(r<a||b<l){return ie;}
		if(a<=l&&r<=b){return dat[k];}
		Flz(k);
		return Dt.Cm(Fge(a,b,k<<1,l,l+ha[k<<1]-1),Fge(a,b,(k<<1)+1,l+ha[k<<1],r),ha[k<<1]);
	}
	public void Add(int a,int b,long d1){Fad(a,b,1,0,n-1,d1);}
	private void Fad(int a,int b,int k,int l,int r,long d1){
		if(a<=l&&r<=b){
			dat[k]=Dt.Lm(dat[k],d1);
			dat[k]=Dt.Um(dat[k],d1,ha[k]);
			bo[k]=true;
		}
		else if(r>=a&&b>=l){
			Flz(k);
			Fad(a,b,k<<1,l,l+ha[k<<1]-1,d1);
			Fad(a,b,(k<<1)+1,l+ha[k<<1],r,d1);
			dat[k]=Dt.Cm(dat[k<<1],dat[(k<<1)+1],ha[(k<<1)+1]);
		}
	}
	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private void Flz(int k){
		if(bo[k]&&ha[k]>1){
			if(ha[k<<1]>0){
				dat[k<<1]=Dt.Lm(dat[k<<1],dat[k].lz1);
				dat[k<<1]=Dt.Um(dat[k<<1],dat[k].lz1,ha[k<<1]);
				bo[k<<1]=true;
			}
			if(ha[(k<<1)+1]>0){
				dat[(k<<1)+1]=Dt.Lm(dat[(k<<1)+1],dat[k].lz1);
				dat[(k<<1)+1]=Dt.Um(dat[(k<<1)+1],dat[k].lz1,ha[(k<<1)+1]);
				bo[(k<<1)+1]=true;
			}
			dat[k]=Dt.Cl(dat[k]);
			bo[k]=false;
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 72508