//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 998244353;
int32_t main(){
        IOS;
       
        int n, q; cin >> n >> q;
        int ansr = 0;
        int x = 1;
        for(int i = 0; i < n; i++){
                ansr += x;
                x *= 10;
                x %= Mod;
                ansr %= Mod;
        }
        vector<vector<int> > a(10, vector<int> (200005));
        for(int i = 0; i < 10; i++){
                int x = i;
                a[i][0] = 0;
                for(int j = 1; j < 200005; j++){
                        a[i][j] = x + a[i][j - 1];
                        x *= 10;
                        x %= Mod;
                }
        }
        set<pair<pair<int, int>, int> > st;
        st.insert({{n, 1}, 1});
        while(q--){
                int lx, rx; cin >> lx >> rx;
                int l = n - rx + 1;
                int r = n - lx + 1;
                int x; cin >> x;
                auto it = st.lower_bound({{l, 0}, 0});
                auto it2 = it;
                while(it != st.end() ){

                        if((*it).ff.ff >= l and (*it).ff.ss <= r){
                                int ll = (*it).ff.ss;
                                int rr = (*it).ff.ff;
                                int xx = (*it).ss;
                                it2 = it;
                                it++;
                                st.erase(it2);
                                if(ll < l){
                                        if(rr <= r){
                                                ansr -= a[xx][rr];
                                                ansr += a[xx][l - 1];
                                                st.insert({{l - 1, ll}, xx});
                                        }
                                        else{
                                                ansr -= a[xx][r];
                                                ansr += a[xx][l - 1];
                                                st.insert({{l - 1, ll}, xx});
                                                st.insert({{rr, r + 1}, xx});
                                        }
                                }
                                else if(ll >= l){
                                        if(rr <= r){
                                                ansr -= a[xx][rr];
                                                ansr += a[xx][ll - 1];
                                        }
                                        else{
                                                ansr -= a[xx][r];
                                                ansr += a[xx][ll - 1];
                                                st.insert({{rr, r + 1}, xx});
                                        }
                                }
                        }
                        else break;
                }
                ansr += a[x][r];
                ansr -= a[x][l - 1];
                ansr %= Mod;
                ansr += Mod;
                ansr %= Mod;
                st.insert({{r, l}, x});
                cout << ansr << endl;
        }
        return 0;
}

Measured memory_bytes: 31284