// Username: WillTheBill
// Time of creation: 2020-09-27 15:33
// Original filename: main.cp.cpp

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

// shortcuts
#define pb push_back
#define fi first
#define se second

// IO
#define multitest signed __T; cin >> __T; while(__T--)
void _masterread(){}
template<typename T,typename... V>
void _masterread(T& t, V&... v){cin >> t;_masterread(v...);}
#define read(...)_masterread(__VA_ARGS__)
void _masterprint(){cout << endl;}
template<typename T,typename... V>
void _masterprint(T t, V... v){cout << t;if(sizeof...(v)) cout << " ";_masterprint(v...);}
#define print(...)_masterprint(__VA_ARGS__)

// DEBUG
// colored output???
template <typename T> // start forward declaration
void _print(T t);
template<typename T1,typename T2>
void _print(pair<T1,T2> p);
template<typename T>
void _print(vector<T>v);
template <typename T> // end forward declaration
void _print(T t){cerr<<t;}
template<typename T1,typename T2>
void _print(pair<T1,T2> p){cerr<<"{";_print(p.first);cerr<<", ";_print(p.second);cerr<<"}";}
template<typename T>
void _print(vector<T>v){cerr<<"(";for(unsigned _i=0;_i<v.size();_i++)_print(v[_i]),cerr<<(_i==v.size()-1?"":", ");cerr << ")";}
void _masterdebug(){cerr<<"]\n";}
template<typename T,typename... V>
void _masterdebug(T t,V... v){_print(t);if(sizeof...(v))cerr<<", ";_masterdebug(v...);}
#ifdef __local__
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] = [";_masterdebug(__VA_ARGS__)
#else
#define debug(...) 
#endif

// ordered_set and ordered_map
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2>
using ordered_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;

// TYPES
#define int long long

int MOD = 998244353;
int vals[10][200000];

#define getsum() (vals[lazy[idx]][r] - (l == 0 ? 0 : vals[lazy[idx]][l-1]))

struct ST{
    vector<int> arr;
    vector<int> lazy;
    ST(int N){
        int size = 1;
        while(size < N) size <<= 1;
        arr = vector<int> (size * 2);
        lazy = vector<int> (size * 2);
    }
    int u(int idx, int l, int r, int ql, int qr, int qval){
        if(ql > r || qr < l) return (lazy[idx] == 0 ? arr[idx] : (getsum() + MOD) % MOD);
        if(l >= ql && r <= qr){
            lazy[idx] = qval;
            arr[idx] = (getsum() + MOD) % MOD;
            if(l != r){
                lazy[idx*2] = lazy[idx];
                lazy[idx*2+1] = lazy[idx];
            }
            lazy[idx] = 0;
            return arr[idx];
        }
        int m = (l + r) / 2;
        if(lazy[idx] != 0){
            lazy[idx*2] = lazy[idx];
            lazy[idx*2+1] = lazy[idx];
            lazy[idx] = 0;
        }
        arr[idx] = u(idx * 2, l, m, ql, qr, qval) + u(idx * 2 + 1, m + 1, r, ql, qr, qval);
        arr[idx] %= MOD;
        return arr[idx];
    }
};

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N, Q; read(N, Q);
    for(int i = 1; i < 10; i++) vals[i][0] = i;
    for(int i = 1; i < N; i++){
        vals[1][i] = (vals[9][i-1] + vals[1][i-1]) % MOD;
        for(int j = 2; j < 10; j++){
            vals[j][i] = (vals[1][i] + vals[j-1][i]) % MOD;
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 1; j < N; j++){
            vals[i][j] += vals[i][j-1];
            vals[i][j] %= MOD;
        }
    }
    ST st (N);
    st.u(1, 0, N - 1, 0, N - 1, 1);
    while(Q--){
        int l, r, d; read(l, r, d); l--, r--;
        l = N - l - 1;
        r = N - r - 1;
        print(st.u(1, 0, N - 1, r, l, d));
    }
}


Measured memory_bytes: 26996