#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

template<unsigned mod=998244353>struct fp {
   int v; static unsigned get_mod(){return mod;}
   int inv() const{
      int tmp,a=v,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0){x+=mod;} return x;
   }
   fp():v(0){}
   fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}
   fp operator-()const{return fp(-v);}
   fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}
   fp& operator+=(const fp& x){if((v+=x.v)>=(int)mod)v-=mod; return *this;}
   fp& operator-=(const fp& x){if((v+=mod-x.v)>=(int)mod)v-=mod; return *this;}
   fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}
   fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}
   fp operator+(const fp& x)const{return fp(*this)+=x;}
   fp operator-(const fp& x)const{return fp(*this)-=x;}
   fp operator*(const fp& x)const{return fp(*this)*=x;}
   fp operator/(const fp& x)const{return fp(*this)/=x;}
   bool operator==(const fp& x)const{return v==x.v;}
   bool operator!=(const fp& x)const{return v!=x.v;}
}; using Fp=fp<>;

template<typename M,typename N=M>
struct LazySegmentTree{
   using F=function<M(M,M)>; using G=function<M(M,N)>; using H=function<N(N,N)>;
   int sz,height; vector<M> data; vector<N> lazy;
   const F f;const G g; const H h; const M m1; const N n1;
   LazySegmentTree(int n,const F f,const G g,const H h,const M &m1,const N n1):f(f),g(g),h(h),m1(m1),n1(n1){
      sz=1,height=0; while(sz<n)sz<<=1,height++;
      data.assign(2*sz,m1); lazy.assign(2*sz,n1);
   }
   void build(vector<M> v){
      rep(i,0,v.size())data[i+sz]=v[i];
      for(int k=sz-1;k>0;k--)data[k]=f(data[2*k],data[2*k+1]);
   }
   M ref(int k){return lazy[k]==n1?data[k]:g(data[k],lazy[k]);}
   void recalc(int k){while(k>>=1)data[k]=f(ref(2*k),ref(2*k+1));}
   void thrust(int k){for(int i=height;i>0;i--)eval(k>>i);}
   void eval(int k){
      if(lazy[k]!=n1){
         lazy[2*k]=h(lazy[2*k],lazy[k]); lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
         data[k]=ref(k); lazy[k]=n1;
      }
   }
   void set(int a,M x){thrust(a+=sz); data[a]=x; recalc(a);}
   void update(int a,int b,N x){
      thrust(a+=sz); thrust(b+=sz-1);
      for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
         if(l&1)lazy[l]=h(lazy[l],x),++l;
         if(r&1)--r,lazy[r]=h(lazy[r],x);
      }
      recalc(a); recalc(b);
   }
   M query(int a,int b){
      thrust(a+=sz); thrust(b+=sz-1);
      M L=m1,R=m1;
      for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
         if(l&1)L=f(L,ref(l++));
         if(r&1)R=f(ref(--r),R);
      } return f(L,R);
   }
};
//g(f(a,b),c)=f(g(a,c),g(b,c)),g(g(a,b),c)=g(a,h(b,c))

typedef pair<Fp,int> P; //{val,len}

Fp ten[402020],one[402020];

int main(){
   ten[0]=1;
   rep(i,0,201010)ten[i+1]=ten[i]*10;
   one[0]=0;
   rep(i,0,201010)one[i+1]=one[i]*10+1;
   auto f=[&](P a,P b){
      return P(a.first*ten[b.second]+b.first,a.second+b.second);
   };
   auto g=[&](P a,int b){
      if(b==0)return a;
      else return P(one[a.second]*b,a.second);
   };
   auto h=[&](int a,int b){
      if(b==0)return a; else return b;
   };

   int n,q; cin>>n>>q;
   LazySegmentTree<P,int> seg(n,f,g,h,P(0,0),0);
   vector<P> a(n);
   rep(i,0,n)a[i]=P(1,1);
   seg.build(a);

   rep(i,0,q){
      int lb,rb,d; cin>>lb>>rb>>d; lb--;
      seg.update(lb,rb,d);
      Fp res=seg.query(0,n).first;
      cout<<res.v<<endl;
   }
   return 0;
}

Measured memory_bytes: 15652