#include <bits/stdc++.h>
#include <atcoder/segtree>
#include <atcoder/modint>
#include <atcoder/math>
using namespace std;

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long
//using mint = atcoder::modint;

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

using mint = atcoder::modint998244353;

void solve(long long N, long long Q, std::vector<long long> L, std::vector<long long> R, std::vector<long long> D){
    vector<vector<mint>> sum(10, vector<mint>(N+1, 0));
    rep(i,1,N+1) {
        rep(j,1,10) {
            sum[j][i] = sum[j][i-1] + j * atcoder::pow_mod(10, i-1, 998244353);
        }
    }
    mint answer = sum[1][N];
    set<pair<pair<int, int>, int>> ranges; // <<L, R>, D>
    ranges.insert({{1, N}, 1});
    rep(qi,0,Q) {
        auto itr = ranges.lower_bound({{L[qi]+1, 0}, D[qi]});
        itr--;
        while (itr != ranges.end()) {
            int l = itr->first.first, r = itr->first.second, d = itr->second;
            if (l <= L[qi] && R[qi] <= r) {
                answer -= sum[d][N-L[qi]+1] - sum[d][N-R[qi]];
                answer += sum[D[qi]][N-L[qi]+1] - sum[D[qi]][N-R[qi]];
                itr = ranges.erase(itr);
                if (l < L[qi]) ranges.insert({{l, L[qi]-1}, d});
                if (R[qi] < r) ranges.insert({{R[qi]+1, r}, d});
                break;
            } else if (l <= L[qi]) {
                // update [L, r]
                answer -= sum[d][N-L[qi]+1] - sum[d][N-r];
                answer += sum[D[qi]][N-L[qi]+1] - sum[D[qi]][N-r];
                itr = ranges.erase(itr);
                if (l < L[qi]) ranges.insert({{l, L[qi]-1}, d});
            } else if (r <= R[qi]) { // L[qi] < l
                // update [l, r]
                answer -= sum[d][N-l+1] - sum[d][N-r];
                answer += sum[D[qi]][N-l+1] - sum[D[qi]][N-r];
                itr = ranges.erase(itr);
            } else { // L[qi] < l && R[qi] < r
                // update [l, R[qi]]
                answer -= sum[d][N-l+1] - sum[d][N-R[qi]];
                answer += sum[D[qi]][N-l+1] - sum[D[qi]][N-R[qi]];
                itr = ranges.erase(itr);
                ranges.insert({{R[qi]+1, r}, d});
                break;
            }
        }
        ranges.insert({{L[qi], R[qi]}, D[qi]});
        cout << answer.val() << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> L(Q);
    std::vector<long long> R(Q);
    std::vector<long long> D(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
        scanf("%lld",&D[i]);
    }
    solve(N, Q, std::move(L), std::move(R), std::move(D));
    return 0;
}


Measured memory_bytes: 28404