#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T, class U> inline void chmax(T &a, const U &b) { if ((a) < (b)) (a) = (b); }
template <class T, class U> inline void chmin(T &a, const U &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// {{{ include acl-library
// #include <atcoder/fenwicktree>
// #include <atcoder/segtree>
// #include <atcoder/lazysegtree>
// #include <atcoder/string>
// #include <atcoder/math>
// #include <atcoder/convolution>
// #include <atcoder/modint>
// #include <atcoder/dsu>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/scc>
// #include <atcoder/twosat>
// using namespace atcoder;
// }}}

int mod = 998244353;
struct mint {  //{{{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    // ?= operator
    mint& operator+=(const mint a) {
        (x += a.x) %= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        (x += mod - a.x) %= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint& operator/=(const mint& rhs) {
        if (rhs.x == 0) throw runtime_error("mint zero division");
        return *this *= rhs.inv();
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint res(1), x(*this);
        if (n < 0) {
            n = -n;
            x = (*this).inv();
        }
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        if (x == 0) throw runtime_error("inv does not exist");
        return pow(mod - 2);
    }
    // mint inv()const{
    //     int x,y;
    //     int g=extgcd(v,mod,x,y);
    //     assert(g==1);
    //     if(x<0)x+=mod;
    //     return mint(x);
    // }

    bool operator<(const mint& r) const { return x < r.x; }
    bool operator==(const mint& r) const { return x == r.x; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
//}}}

// snippet:segment_tree_lazy {{{
template <typename X, typename M>
struct segment_tree_lazy {
    using FX = function<X(X, X)>;
    using FA = function<X(X, M)>;
    using FM = function<M(M, M)>;
    using index = int;
    int n;  // 元の配列のサイズ
    int N;  // n以上の最小の2冪
    FX merge;
    FA apply;
    FM composite;
    const X ex;
    const M em;
    vector<X> dat;
    vector<M> lazy;
    segment_tree_lazy(FX merge_, FA apply_, FM composite_, X ex_, M em_)
        : merge(merge_), apply(apply_), composite(composite_), ex(ex_), em(em_) {
        }

    void set(index i, X x) { dat[i + n - 1] = x; }
    void init(index n_) { 
        N = 1;
        n = n_;
        while (N < n_) N <<= 1;
        dat.assign(2 * N, ex);
        lazy.assign(2 * N, em);
    } 

    void build(const vector<X> &v) { 
        int n_ = v.size();
        init(n_);
        for (int i = 0; i < n_; i++) dat[i + N - 1] = v[i];
        for (int k = N - 2; k >= 0; k--) dat[k] = merge(dat[2 * k + 1], dat[2 * k + 2]);
    } 

    /* lazy propagate */
    void propagate(int k) {
        if (lazy[k] == em) return;  // 更新するものが無ければ終了
        if (k < N - 1) {            // 葉でなければ子に伝搬
            lazy[k * 2 + 1] = composite(lazy[k * 2 + 1], lazy[k]);
            lazy[k * 2 + 2] = composite(lazy[k * 2 + 2], lazy[k]);
        }
        // 自身を更新
        dat[k] = apply(dat[k], lazy[k]);
        lazy[k] = em;
    }

    void update(index a, index b, M x) { update(a, b, x, 0, 0, N); }
    void update(index a, index b, M x, int k, index l, index r) {
        if (a <= l && r <= b) {  // 完全に内側の時
            lazy[k] = composite(lazy[k], x);
            propagate(k);
        }
        else if (a < r && l < b) {                     // 一部区間が被る時
            propagate(k);
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);  // 左の子
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);  // 右の子
            dat[k] = merge(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
        else{
            propagate(k);
        }
    }

    X query(index a, index b) { return query_sub(a, b, 0, 0, N); }
    X query_sub(index a, index b, int k, index l, index r) {
        propagate(k);
        if (r <= a || b <= l) {  // 完全に外側の時
            return ex;
        }
        else if (a <= l && r <= b) {  // 完全に内側の時
            return dat[k];
        }
        else {  // 一部区間が被る時
            X lv = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X rv = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return merge(lv, rv);
        }
    }

    index find_most_left(index l, const function<bool(X)>& is_ok){
        // lから右に探していってis_okが初めて成り立つようなindexを返す。
        // assume query(l, *) has monotonity
        // return index i s.t is_ok(query(l, i)) does not holds, but is_ok(query(l, i+1)) does.
        // if such i does not exist, return n
        index res = _find_most_left(l, is_ok, 0, 0, N, ex).first;
        assert(l <= res);
        return res;
    }
    pair<index, X> _find_most_left(index a, const function<bool(X)>& is_ok, int k, index l, index r, X left_value){
        // params:
        // left_value = (a < l ? query(a, l) : ex)
        // return (index i, X v)
        // i is the index in [a, n)^[l, r) s.t query(a, i+1) is ok but query(a, i) isn't ok. if such i does not exist, i = n
        // v is the value s.t query(a, r)

        propagate(k);
        if (r <= a) return {n, ex};  // 区間が全く被っていない
        else if (a <= l && !is_ok(merge(left_value, dat[k]))) return {n, merge(left_value, dat[k])};
        else if (k >= N-1) return {k - (N-1), merge(left_value, dat[k])};
        else{
            auto [vl, xl] = _find_most_left(a, is_ok, 2 * k + 1, l, (l + r) / 2, left_value);
            if (vl != n) return {vl, xl};
            auto [vr, xr] = _find_most_left(a, is_ok, 2 * k + 2, (l + r) / 2, r, xl);
            return {vr, xr};
        }
    }

    index find_most_right(index r, const function<bool(X)>& is_ok){
        // rから左に探していってis_okが初めて成り立つようなindexを返す。
        // assume query(*, r) has monotonity
        // return index i s.t is_ok(query(i+1, r+1)) does not holds, but is_ok(query(i, r+1)) does.
        // if such i does not exist, return -1
        index res = _find_most_right(r+1, is_ok, 0, 0, N, ex).first;
        assert(res <= r);
        return res;
    }
    pair<index, X> _find_most_right(index b, const function<bool(X)>& is_ok, int k, index l, index r, X right_value){
        propagate(k);
        if (b <= l) return {-1, ex};  // 区間が全く被っていない
        else if (r <= b && !is_ok(merge(dat[k], right_value))) return {-1, merge(dat[k], right_value)};
        else if (k >= N-1) return {k - (N-1), merge(dat[k], right_value)};
        else{
            auto [vr, xr] = _find_most_right(b, is_ok, 2 * k + 2, (l + r) / 2, r, right_value);
            if (vr != -1) return {vr, xr};
            auto [vl, xl] = _find_most_right(b, is_ok, 2 * k + 1, l, (l + r) / 2, xr);
            return {vl, xl};
        }
    }

    /* debug */
    inline X operator[](int i) { return query(i, i + 1); }

#if defined(PCM) || defined(LOCAL)
    friend ostream& operator<<(ostream& os, segment_tree_lazy& sg) {  //
        os << "[";
        for (int i = 0; i < sg.n; i++) {
            os << sg[i] << (i == sg.n - 1 ? "]\n" : ", ");
        }
        return os;
    }
#endif
};
// Regarding apply and merge, the conditions below should holds.
// apply(merge(x1, x2), m) = merge(apply(x1, m), apply(x2, m))
// apply(apply(x, m1), m2) = apply(x, composition(m1, m2))
// composition(m, em) = m && composition(em, m) = m && apply(x, em) = x
// snippet:segment_tree_lazy }}}

template<class T>
struct monoid_with_len {
    T x;
    T len;
    monoid_with_len(){};
    monoid_with_len(T x_, T len_) : x(x_), len(len_){};
};
template<class T>
monoid_with_len<T> operator+(monoid_with_len<T> a, monoid_with_len<T> b){
    return monoid_with_len<T>(a.x + b.x, a.len + b.len);
}

using X = monoid_with_len<mint>; // (X, merge) is monoid
using M = mint; // (M, composition) is monoid
auto make_lseg_rsq_raq(){
    auto merge = [](X x1, X x2){return x1 + x2;};
    X ex = X(0, 0);
    M em = 0;
    auto composition = [=](M m1, M m2){ 
        if (m1 == em) return m2;
        if (m2 == em) return m1;
        return m2;
    };
    auto apply = [](X x, M m){return X(m*x.len, x.len);};
    return segment_tree_lazy<X, M>(merge, apply, composition, ex, em);
}


int solve() {
    ll n,Q;cin>>n>>Q;
    vec<mint> r(n);
    r[0] = 1;
    rep(i, 1, n){
        r[i] = r[i-1]*10;
        dump(r[i]);
    }

    auto seg = make_lseg_rsq_raq();
    vec<X> b(n);
    rep(i, n){
        b[i] = X(r[i], r[i]);
    }
    seg.build(b);

    rep(q, Q){
        int l,r;cin>>l>>r;
        l--;r--;
        int nl = n-1-r;
        int nr = n-1-l;
        dump(l, r);
        dump(nl, nr);
        int d;cin>>d;
        seg.update(nl, nr+1, d);
        cout << seg.query(0, n).x << endl;
    }

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 20372