#include <bits/stdc++.h>

using namespace std;
const int hell = 998244353;
const int MOD=hell;
struct Mint {
    int _val;
 
    Mint(long long _v = 0) {
        if (_v < 0)
            _v = _v % MOD + MOD;
        if (_v >= MOD)
            _v %= MOD;
        _val = _v;
    }
 
    static int mod_inv(int _a, int _m = MOD) {
        int _g = _m, _r = _a, _x = 0, _y = 1;
        while (_r != 0) {
            int q = _g / _r;
            _g %= _r; swap(_g, _r);
            _x -= q * _y; swap(_x, _y);
        } 
        return _x < 0 ? _x + _m : _x;
    } 
    explicit operator int() const {
        return _val;
    }
    Mint& operator+=(const Mint &other) {
        _val += other._val;
        if (_val >= MOD) _val -= MOD;
        return *this;
    }
    Mint& operator-=(const Mint &other) {
        _val -= other._val;
        if (_val < 0) _val += MOD;
        return *this;
    }
    static unsigned fast_mod(uint64_t _x, unsigned _m = MOD) {
           #if !defined(_WIN32) || defined(_WIN64)
                return _x % _m;
           #endif
           unsigned x_high = _x >> 32, x_low = (unsigned) _x;
           unsigned quot, rem;
           asm("divl %4\n"
            : "=_a" (quot), "=d" (rem)
            : "d" (x_high), "a" (x_low), "r" (_m));
           return rem;
    }
    Mint& operator*=(const Mint &other) {
        _val = fast_mod((uint64_t) _val * other._val);
        return *this;
    }
    Mint& operator/=(const Mint &other) {
        return *this *= other.inv();
    }
    friend Mint operator+(const Mint &_a, const Mint &b) { return Mint(_a) += b; }
    friend Mint operator-(const Mint &_a, const Mint &b) { return Mint(_a) -= b; }
    friend Mint operator*(const Mint &_a, const Mint &b) { return Mint(_a) *= b; }
    friend Mint operator/(const Mint &_a, const Mint &b) { return Mint(_a) /= b; }
    Mint& operator++() {
        _val = _val == MOD - 1 ? 0 : _val + 1;
        return *this;
    }
    Mint& operator--() {
        _val = _val == 0 ? MOD - 1 : _val - 1;
        return *this;
    }
    Mint operator++(int32_t) { Mint before = *this; ++*this; return before; }
    Mint operator--(int32_t) { Mint before = *this; --*this; return before; }
    Mint operator-() const {
        return _val == 0 ? 0 : MOD - _val;
    }
    bool operator==(const Mint &other) const { return _val == other._val; }
    bool operator!=(const Mint &other) const { return _val != other._val; }
    Mint inv() const {
        return mod_inv(_val);
    }
    Mint power(long long _p) const {
        assert(_p >= 0);
        Mint _a = *this, result = 1;
        while (_p > 0) {
            if (_p & 1)
                result *= _a;
 
            _a *= _a;
            _p >>= 1;
        }
        return result;
    }
    friend ostream& operator << (ostream &stream, const Mint &_m) {
        return stream << _m._val;
    }
    friend istream& operator >> (istream &stream, Mint &_m) {
        return stream>>_m._val;   
    }
};

Mint p[(int)2e5 + 5];
struct segtree{
    vector<Mint> operations, val;
    int sz;
    int n;
    Mint NO_OPERATION;
    Mint NEUTRAL_ELEMENT;
    int le(int x){ return 2 * x + 1; }
    int ri(int x){ return 2 * x + 2; }
    void merge(Mint &res, Mint fi, Mint se, int len)
    {
        res = fi;
        res += se;
        return ;
    }
    void propagate(int x, int lx, int rx)
    {
        if(rx - lx == 1)return ;
        if(operations[x] == NO_OPERATION)return;
        operations[le(x)] = operations[x];
        operations[ri(x)] = operations[x];
        int mx = (lx + rx) >> 1;
        Mint mult = p[mx];
        mult -= p[lx];
        val[le(x)] = (mult) * operations[x];
        mult = p[rx];
        mult -= p[mx];
        val[ri(x)] = ( mult ) * operations[x];
        operations[x] = NO_OPERATION;
        return ;
    }
    void build(int x, int lx, int rx)
    {
        if(rx - lx == 1)
        {
            if(lx < n){
                val[x] = p[rx];
                val[x] -= p[lx];
            }
            return ;
        }
        int mx = (lx + rx) >> 1;
        build(le(x), lx, mx);
        build(ri(x), mx, rx);
        merge(val[x], val[le(x)], val[ri(x)], rx - mx);
    }
    void init(int f)
    {
        sz = 1;
        n = f;
        NO_OPERATION = 0;
        NEUTRAL_ELEMENT = 0;
        while(sz < f)
            sz *= 2;
        operations.assign(2 * sz, 0);
        val.assign(2 * sz, 0);
        return build(0, 0, sz);
    }
    void upd(int l, int r, int digi, int x, int lx, int rx)
    {
        propagate(x, lx, rx);
        if(r <= lx or l >= rx)return ;
        if(r >= rx and lx >= l)
        {
            operations[x] = digi;
            Mint mulp = p[rx];
            mulp -= p[lx];
            val[x] = (mulp) * digi;
            return ;
        }
        int mx = (lx + rx) >> 1;
        upd(l, r, digi, le(x), lx, mx);
        upd(l, r, digi, ri(x), mx, rx);
        merge(val[x], val[le(x)], val[ri(x)], rx - mx);
        return ;
    }
    void upd(int l, int r, int digi)
    {
        return upd(l, r, digi, 0, 0, sz);
    }
    Mint query(int l, int r, int x, int lx, int rx)
    {
        propagate(x, lx, rx);
        if(l >= rx or r <= lx)return NEUTRAL_ELEMENT;
        if(l <= lx and r >= rx)
        {
            return val[x];
        }
        int mx = (lx + rx) >> 1;
        Mint res = 0;
        res += query(l, r, le(x), lx, mx);
        res += query(l, r, ri(x), mx, rx);
        return res;
    }
    Mint query(int l, int r)
    {
        return query(l, r, 0, 0, sz);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int n, q;
    cin >> n >> q;
    p[0] = 0;
    for(int i = 1; i < n + 1; i++)
    {
        p[i] = (p[i - 1] * 10) + 1;
    }
    segtree st;
    st.init(n);
    
    while(q--)
    {
        int l, r, digi;
        cin >> l >> r >> digi;
        l = n - l;
        r = n - r;
        l++;
        st.upd(r, l, digi);
        cout << st.query(0, n) << endl;
    }
}

Measured memory_bytes: 8220