#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=998244353;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#include <functional>

template< typename T, typename S >
struct LazySegmentTree{
    int n;
    vector<T> data;
    vector<S> lazy;
    T te;
    S se;
    vector<vector<ll>> dp;
    vector<ll> ten;

    inline void merge_functions(S& lazy,S& val){
        //lazy+=val;
        lazy=val;
    }
    inline void operate(T& data,S& val,int len){
        //data+=val*len;
        //data=val*len;
        //data+=val;
        data.val=dp[val][len];
    }
    inline T merge_values(T& x,T& y){
        //return x+y;
        //return min(x,y);
        //return max(x,y);
        ll res=(x.val*ten[y.len]+y.val)%MOD;
        return {res,x.len+y.len};
    }

    LazySegmentTree(){}
    LazySegmentTree(int sz,T te,S se):te(te),se(se){
        n=1;
        while(n<sz) n*=2;
        data.resize(2*n-1,te);
        lazy.resize(2*n-1,se);
        dp.resize(10);
        ten.resize(sz+1,0);
        ten[0]=1;
        for(int i=1;i<=sz;i++) ten[i]=ten[i-1]*10%MOD;
        for(int i=1;i<=9;i++){
          dp[i].resize(sz+1,0);
          for(int j=1;j<=sz;j++){
            dp[i][j]=(dp[i][j-1]*10+i)%MOD;
          }
        }
    }

    void build(const vector<T> &A){
        for(int k=0;k<int(A.size());k++) data[k+n-1]=A[k];
        for(int k=n-2;k>=0;k--) data[k]=merge_values(data[2*k+1],data[2*k+2]);
    }

    void eval(int k,int l,int r){
        if(lazy[k]==se) return;
        operate(data[k],lazy[k],r-l);
        if(r-l>1){
            merge_functions(lazy[2*k+1],lazy[k]);
            merge_functions(lazy[2*k+2],lazy[k]);
        }
        lazy[k]=se;
    }

    void update(int a,int b,S val,int k=0,int l=0,int r=-1){
        if(r<0) r=n;
        eval(k,l,r);
        if(b<=l||r<=a) return;
        if(a<=l&&r<=b){
            merge_functions(lazy[k],val);
            eval(k,l,r);
        }else{
            update(a,b,val,2*k+1,l,(l+r)/2);
            update(a,b,val,2*k+2,(l+r)/2,r);
            data[k]=merge_values(data[2*k+1],data[2*k+2]);
        }
    }

    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0) r=n;
        eval(k,l,r);
        if(b<=l||r<=a) return te;
        if(a<=l&&r<=b) return data[k];

        T vl=query(a,b,2*k+1,l,(l+r)/2);
        T vr=query(a,b,2*k+2,(l+r)/2,r);
        return merge_values(vl,vr);
    }

    T get(int p){
        return query(p,p+1);
    }
};

/*
  LazySegmentTree<ll,ll> seg(N,te,se);
  vector<ll> init(N,0);
  seg.build(init);
*/

struct M{
  ll val;
  int len;
  M(){}
  M(ll a,int l):val(a),len(l){}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N,Q;
  cin>>N>>Q;

  LazySegmentTree<M,int> seg(N,M{0,0},0);
  seg.build(vector<M> (N,M{1,1}));

  rep(q,Q){
    int L,R;
    char C;
    cin>>L>>R>>C;
    L--;R--;

    int d=C-'0';
    seg.update(L,R+1,d);

    cout<<seg.query(0,N).val<<endl;
  }

  return 0;
}


Measured memory_bytes: 32236