#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

#ifdef LOCAL
#include "../ACL.hpp"
#else
#include <atcoder/all>
#endif

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr int MOD = 998244353;

template<class T> inline T sqr(T x) {return x*x;}

// auto mod int
struct mint {
    LL x;
    mint(LL x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    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(const LL &t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    LL operator()() const {
        return x;
    }
};
using VM = vector<mint>;
using VVM = vector<VM>;

void solve() {
    LL n,q;
    cin >> n >> q;
    // mint ans = 0;
    // REP(i,0,n) ans = ans * 10 + 1;
    VM ps(200000);
    ps[0] = 1;
    REP(i,1,200000) ps[i] = ps[i-1] * 10;
    VI vs(200000+1);
    REP(i,0,n) vs[i] = 1;
    mint unit = 0;
    REP(i,0,500) unit = unit * 10 + 1;
    VM ss(400);
    vector<bool> alls(400);
    VI allv(400);
    REP(i,0,400) {
        // dump(i);
        if ((i+1)*500 <= n) {
            ss[i] = unit;
            alls[i] = true;
            allv[i] = 1;
        } else {
            REP(j,i*500,n) {
                vs[j] = 1;
                ss[i] = ss[i] * 10 + 1;
            }
            break;
        }
    }

    // {
    //     mint ans = 0;
    //     REP(i,0,400) {
    //         ans += ss[i] * ps[i*500];
    //     }
    //     cout << ans() << endl;
    //     dump(ss[0]());
    // }

    int l,r,d;
    REP(i,0,q) {
        cin >> l >> r >> d;
        l = n - l;
        r = n - r;
        swap(l,r);
        // dump(l);
        // dump(r);
        // REP(j,l,r+1) {
        //     int diff = d - vs[j];
        //     ans += ps[j] * diff;
        //     vs[j] = d;
        // }
        // dump(i);
        if (alls[l/500]) {
            alls[l/500] = false;
            REP(k,(l/500)*500,(l/500+1)*500) if (k < n) vs[k] = allv[l/500];
        }
        // dump(i);
        if (alls[r/500]) {
            alls[r/500] = false;
            REP(k,(r/500)*500,(r/500+1)*500) if (k < n) vs[k] = allv[r/500];
        }
        // dump(i);
        REP(j,l,min(r+1,((l+500-1)/500)*500)) {
            int diff = d - vs[j];
            ss[l/500] += ps[j%500] * diff;
            vs[j] = d;
        }
        // dump(i);
        REP(j,max(l,(r/500)*500),r+1) {
            int diff = d - vs[j];
            ss[r/500] += ps[j%500] * diff;
            vs[j] = d;
        }
        // dump(i);
        REP(j,((l+500-1)/500),r/500) {
            ss[j] = unit * d;
            alls[j] = true;
            allv[j] = d;
        }
        // dump(i);
        mint ans = 0;
        REP(i,0,400) {
            ans += ss[i] * ps[i*500];
        }
        cout << ans() << endl;
    }

}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 5620