//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#include <random>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//#ifdef __int128
using hll = __int128;

using ll = long long;
//#endif
using pii = pair<ll, ll>;
using ld = double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 998244353;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

ll sub(ll a, ll b) {
    return add(a, mod - b);
}

const int MAXN = 3e5 + 32;


int t[8 * MAXN];
int sums[8 * MAXN];

ll pows[MAXN];


ll sq(ll v) {
    return ml(v, v);
}

ll b_p(ll b, ll p) {
    if (p == 0)
        return 1;
    if (p & 1)
        return ml(b, b_p(b, p ^ 1));
    return sq(b_p(b, p >> 1));
}

ll b9;

ll getsum(ll l, ll r){
    ll diff = sub(pows[r + 1], pows[l]);
    return ml(diff, b9);
}



int n, q;

void push (int v, int l, int r) {
    if (t[v] != -1) {
        ll mid = (l + r) >> 1;
        t[v * 2] = t[v * 2 + 1] = t[v];
        sums[2 * v] = ml(t[2 * v], getsum(n - mid - 1l, n - l - 1));
        sums[2 * v + 1] = ml(t[2 * v + 1], getsum(n - r - 1, n - mid - 2));

        sums[v] = add(sums[2 * v], sums[2 * v + 1]);

        t[v] = -1;
//        sums[v] = 0;
    }
}


void update (int v, int tl, int tr, int l, int r, int color) {
    push(v, tl, tr);
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = color;
        push(v, tl, tr);
    } else {
        int tm = (tl + tr) / 2;
        update(v * 2, tl, tm, l, min(r, tm), color);
        update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, color);
    }

    sums[v] = add(sums[2 * v], sums[2 * v + 1]);
}

ll summ(int v, int tl, int tr, int l, int r) {

    push(v, tl, tr);

    if (l > r) return 0;

    if (tr == r && tl == l) {
        return sums[v];
    }

    int mid = (tl + tr) >> 1;

    return add(summ(2 * v, tl, mid, l, min(r, mid)), summ(2 * v + 1, mid + 1, tr, max(mid + 1, l), r));
}

void solve() {

    cin >> n >> q;

    b9 =  b_p(9, mod - 2);

    ll b = 10;
    pows[0] = 1;
    for (int i = 1; i <= n; ++i) {
        pows[i] = ml(b, pows[i - 1]);
    }


    ll answr = 0;

    update(1, 0, n - 1, 0, n - 1, 1);
    answr = add(answr, summ(1, 0, n - 1, 0, n - 1));

    for (int i = 0; i < q; ++i) {
        int l, r, d;
        cin >> l >> r >> d;

        --l;
        --r;

        ll s = summ(1, 0, n - 1, l, r);

        update(1, 0, n - 1, l, r, d);

        answr = sub(answr, s);
        s = summ(1, 0, n - 1, l, r);

        answr = add(answr, s);

        cout << answr << "\n";
    }
}


#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case " << i << ": ";
        solve();
//        cout << "\n";
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
#else
#endif
#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 13428