#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
template<typename T, typename U>
struct lazy_segment_tree{
    int n;
    int H;
    T base;
    vector<T> segtree;
    vector<U> lazytree;
    vector<bool> isempty;
    function<T(const T&, const T&)> join;
    function<T(int, const U&, const T&)> assign;
    function<U(const U&,const U&)> lazyassign;

    lazy_segment_tree(vector<T> &seq, 
    function<T(const T&, const T&)> join, 
    function<T(int, const U&, const T&)> assign,
    function<U(const U&,const U&)> lazyassign,
    T base) : join(join), assign(assign), lazyassign(lazyassign), base(base){
        n = seq.size();
        H = 32 - __builtin_clz(n);
        segtree.resize(2*n);
        lazytree.resize(n);
        isempty.resize(n,1);
        for(int i=0;i<n;i++){
            segtree[n+i]=seq[i];
        }
        for(int i=n-1;i>=1;i--){
            segtree[i]=join(segtree[(i<<1)], segtree[(i<<1)|1]);
        }
    }
    void calc(int pos, int h){
        segtree[pos]=join(segtree[(pos<<1)],segtree[(pos<<1)|1]);
        if(!isempty[pos]){
            segtree[pos]=assign(h,lazytree[pos],segtree[pos]);
        }
    }
    void apply(int pos, U value, int h){
        segtree[pos]=assign(h, value, segtree[pos]);
        if(pos<n){
            if(!isempty[pos]){
                lazytree[pos]=lazyassign(lazytree[pos], value);
            }
            else{
                lazytree[pos] = value;
            }
            isempty[pos]=0;
        }
    }
    void updatenode(int pos){
        int h=0;
        pos+=n;
        while(pos>1){
            h++;
            pos>>=1;
            calc(pos, h);
        }
    }
    void push(int pos){
        int h=H;
        for(pos+=n;h;--h){
            int x=(pos>>h);
            if(!isempty[x]){
                apply((x<<1), lazytree[x], h-1);
                apply((x<<1)|1, lazytree[x], h-1);
                isempty[x]=1;
            }
        }
    }
    void updaterange(int l, int r, U value){
        push(l);
        push(r);
        int k=0;
        int l0=l, r0=r;
        for(l+=n, r+=n+1;l<r;l>>=1, r>>=1, k++){
            if(l&1){
                apply(l++, value, k);
            }
            if(r&1){
                apply(--r, value,k);
            }
        }
        updatenode(l0);
        updatenode(r0);
    }
    T query(int l, int r){
        push(l);
        push(r);
        T ansl=base;
        T ansr=base;
        for(l+=n,r+=n+1;l<r;l>>=1,r>>=1){
            if(l&1){
                ansl=join(ansl, segtree[l++]);
            }        
            if(r&1){
                ansr=join(segtree[--r], ansr);
            }
        }
        return join(ansl,ansr);
    }
    void debug(){
        for(int i=0;i<2*n;i++){
            cout<<segtree[i].first<<" "<<segtree[i].second<<"\n";
        }
        for(int i=0;i<n;i++) cout<<lazytree[i]*isempty[i]<<" ";
        cout<<"\n";
    }
};
const int p = 998244353;
void solve(){
    int n;
    cin>>n;
    vector<array<ll,10>> lazyset(n+1);
    for(int j=0;j<=9;j++){
        lazyset[0][j] = 0;
        for(int i=1;i<=n;i++){
            lazyset[i][j] = lazyset[i-1][j]*10 + j;
            lazyset[i][j]%=p;
        }
    }
    vector<ll> p10(n+1);
    p10[0] = 1;
    for(int i=1;i<=n;i++){
        p10[i] = p10[i-1]*10%p;
    }
    vector<pair<ll,int>> seq(n, {1,1});
    lazy_segment_tree<pair<ll,int>,int> segtree(seq, [&](const pair<ll,int> &x, const pair<ll,int> &y){
        return mp((x.first*p10[y.second] + y.first)%p, x.second + y.second);
    }, 
    [&](int h,const int &lazy, const pair<ll,int> &x){
        return mp(lazyset[x.second][lazy], x.second);
    },
    [&](const int &l1,const int &l2) ->int{
        return l2;
    },{0,0});
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int l,r,d;
        cin>>l>>r>>d;
        --l;--r;
        segtree.updaterange(l,r,d);
        cout<<segtree.query(0,n-1).first<<"\n";
        //segtree.debug();
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 30660