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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=2e5+5,mod=998244353,bit=61;

int pw[N],pref[N];

int get_sum(int l,int r)
{
    return (pref[r]-pref[l-1]+mod)%mod;
}

template<typename T>
class segment
{
    public:
        int n;
        vector<T> st;
        vector<bool> isleft;
        vector<long long> lazy;


        segment() {}

        segment(int _n)
        {
            n=_n;
            st.resize(4*n+10);
            isleft.resize(4*n+10,0);
            lazy.resize(4*n+10,0);

        }

        T merge(T &a,T &b)
        {
            T res=a+b;
            res%=mod;
            return res;
        }

        void propagate(int si,int l,int r)
        {
            if(l!=r)
            {
                isleft[2*si]=1;
                isleft[2*si+1]=1;
                lazy[2*si]=lazy[si];
                lazy[2*si+1]=lazy[si];
            }
            st[si]=(lazy[si] * get_sum(l,r))%mod;
            lazy[si]=0;
            isleft[si]=0;
        }

        void create(int si,int l,int r)
        {
            if(l==r)
            {
                st[si]=pw[l];
                return;
            }
            int mid=(l+r)>>1;
            create(2*si,l,mid);
            create(2*si+1,mid+1,r);
            st[si]=merge(st[2*si],st[2*si+1]);
        }

        void update(int si,int l,int r,int ql,int qr,int val)
        {
            if(isleft[si])
            {
                propagate(si,l,r);
            }
            if(ql>r or qr<l or l>r)
            {
                return;
            }
            if(ql<=l and qr>=r)
            {
                isleft[si]=1;
                lazy[si]=val;
                propagate(si,l,r);
                return;
            }
            int mid=(l+r)>>1;
            update(2*si,l,mid,ql,qr,val);
            update(2*si+1,mid+1,r,ql,qr,val);
            st[si]=merge(st[2*si],st[2*si+1]);
        }

        T query(int si,int l,int r,int ql,int qr)
        {
            if(isleft[si])
            {
                propagate(si,l,r);
            }
            if(ql>r or qr<l or l>r)
            {
                return 0;
            }
            if(ql<=l and qr>=r)
            {
                return st[si];
            }
            int mid=(l+r)>>1;
            T ansl=query(2*si,l,mid,ql,qr);
            T ansr=query(2*si+1,mid+1,r,ql,qr);
            T ans=merge(ansl,ansr);
            return ans;
        }
};



signed main()
{
    fast;

    int n,q;
    cin>>n>>q;
    pw[n]=1;

    rf(i,n-1,1)
    {
        pw[i]=(pw[i+1] * 10)%mod;
    }

    pw[0]=0;
    f(i,1,n)
    {
        pref[i]=(pref[i-1] + pw[i])%mod;
    }


    segment<int> obj(n);
    obj.create(1,1,n);
    f(i,1,q)
    {
        int l,r;
        char ch;
        cin>>l>>r>>ch;
        int d= ch-'0';
        obj.update(1,1,n,l,r,d);
        cout<<obj.query(1,1,n,1,n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 19036