#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for(int i = 0; i < (int)(n) ; i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

const long long MOD = 998244353;

template<int M, bool IsPrime = false>
class Modulo {
    int n;

    static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
        return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
    }

public:
    Modulo() : n(0) { ; }

    Modulo(int m) : n(m) {
        if (n >= M)
            n %= M;
        else if (n < 0)
            n = (n % M + M) % M;
    }

    Modulo(ll m) {
        if (m >= M)
            m %= M;
        else if (m < 0)
            m = (m % M + M) % M;
        n = m;
    }

    explicit operator int() const { return n; }

    explicit operator ll() const { return n; }

    bool operator==(const Modulo &a) const { return n == a.n; }

    Modulo &operator+=(const Modulo &a) {
        n += a.n;
        if (n >= M) n -= M;
        return *this;
    }

    Modulo &operator-=(const Modulo &a) {
        n -= a.n;
        if (n < 0) n += M;
        return *this;
    }

    Modulo &operator*=(const Modulo &a) {
        n = (ll(n) * a.n) % M;
        return *this;
    }

    Modulo operator+(const Modulo &a) const {
        Modulo res = *this;
        return res += a;
    }

    Modulo operator-(const Modulo &a) const {
        Modulo res = *this;
        return res -= a;
    }

    Modulo operator-() const { return Modulo(0) - *this; }

    Modulo operator*(const Modulo &a) const {
        Modulo res = *this;
        return res *= a;
    }

    Modulo operator^(ll m) const {
        if (m == 0) return Modulo(1);
        const Modulo a = *this;
        Modulo res = (a * a) ^(m / 2);
        return m % 2 ? res * a : res;
    }

    typename std::enable_if<IsPrime, Modulo>::type
    operator/(const Modulo &a) const {
        return *this * inv(ll(a), M);
    }

    typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
        return *this *= inv(ll(a), M);
    }

    friend bool is_zero(const Modulo &x) { return int(x) == 0; }

    friend int abs(const Modulo &x) { return int(x); }

    static Modulo fact(int n, bool sw = true) {
        static std::vector<Modulo> v1 = {1}, v2 = {1};
        if (n >= (int) v1.size()) {
            const int from = v1.size(), to = n + 1024;
            v1.reserve(to);
            v2.reserve(to);
            for (int i = from; i < to; ++i) {
                v1.push_back(v1.back() * Modulo<M, true>(i));
                v2.push_back(v2.back() / Modulo<M, true>(i));
            }
        }
        return sw ? v1[n] : v2[n];
    }

    static Modulo comb(int a, int b) {
        if (b < 0 || b > a) return 0;
        return Modulo::fact(a, true) * Modulo::fact(b, false) *
               Modulo::fact(a - b, false);
    }
};

typedef Modulo<MOD, true> mInt;

template<typename T>
class CumulativeSum {
    int n;
    std::vector<T> sum_data;
public:
    CumulativeSum() {
    }

    CumulativeSum(vector<T> data) : n(data.size()) {
        sum_data.resize(n + 1);
        for (int i = 0; i < n; i++) {
            sum_data[i + 1] = sum_data[i] + data[i];
        }
    }

    // 区間 [l, r) 番目の範囲の和を求める．(l = r のときは 0 を返す．)
    T sum(int l, int r) const {
        assert(0 <= l && l <= r && r <= n);
        return sum_data[r] - sum_data[l];
    }
};

typedef CumulativeSum<mInt> CumSum;
CumSum cumSum;


int log2ceil(int n) {
    --n;
    n |= n >> 16;
    n |= n >> 8;
    n |= n >> 4;
    n |= n >> 2;
    n |= n >> 1;
    return n + 1;
}

template<typename Struct>
class SegmentTreeLazy {
public:
    using Monoid = typename Struct::Monoid;
    using Update = typename Struct::Update;
    using value_type = typename Struct::value_type;
    using update_type = typename Struct::update_type;

private:
    const int n;
    std::vector<value_type> data;
    std::vector<update_type> lazy;
    std::vector<bool> flag;

    void lazyset(int node, const update_type &update) {
        if (node < n) {
            if (flag[node]) {
                lazy[node] = Update::op(update, lazy[node]);
            } else {
                lazy[node] = update;
                flag[node] = true;
            }
        }
        data[node] = Struct::evaluate(update, data[node]);
    }

    void evaluate(int node) {
        if (!flag[node]) return;
        flag[node] = false;
        lazyset(node * 2 + 0, lazy[node]);
        lazyset(node * 2 + 1, lazy[node]);
    }

    void update_sub(int l, int r, int node, int lb, int ub,
                    const update_type &update) {
        if (ub <= l || r <= lb) {
            return;
        }
        if (l <= lb && ub <= r) {
            lazyset(node, update);
            return;
        }
        evaluate(node);
        const int mid = (lb + ub) / 2;
        update_sub(l, r, node * 2 + 0, lb, mid, update);
        update_sub(l, r, node * 2 + 1, mid, ub, update);
        data[node] = Monoid::op(data[node * 2 + 0], data[node * 2 + 1]);
    }

    value_type query_sub(int l, int r, int node, int lb, int ub) {
        if (ub <= l || r <= lb) return Monoid::id();
        if (l <= lb && ub <= r) {
            return data[node];
        }
        evaluate(node);
        const int mid = (lb + ub) / 2;
        value_type lval = query_sub(l, r, node * 2 + 0, lb, mid);
        value_type rval = query_sub(l, r, node * 2 + 1, mid, ub);
        return Monoid::op(lval, rval);
    }

public:
    SegmentTreeLazy(const vector<value_type> init) :
            n(log2ceil(init.size())), data(n * 2), lazy(n), flag(n, false) {
        copy(init.begin(), init.end(), begin(data) + n);
        for (int i = n - 1; i >= 1; i--) {
            data[i] = Monoid::op(data[i * 2 + 0], data[i * 2 + 1]);
        }
    };

    void update(int l, int r, const update_type &f) {
        update_sub(l, r, 1, 0, n, f);
    }

    value_type query(int l, int r) {
        return query_sub(l, r, 1, 0, n);

    }
};


template<class T>
struct RangeData {
    int l, r;
    T v;

    RangeData() {
        l = r = -1;
        v = T();
    }

    RangeData(int l, int r, T v) : l(l), r(r), v(v) {}

    bool invalid() const {
        return l == -1;
    }

    static vector<RangeData<T>> build_rmq_array(const vector<T> &vs) {
        vector<RangeData<T>> res(vs.size());
        for (int i = 0; i < vs.size(); i++) {
            res[i] = RangeData<T>(i, i + 1, vs[i]);
        }
        return res;
    }
};


// RMQ + range_add
struct RMQ {
    using value_type = RangeData<mInt>;

    static value_type id() { return value_type(); }

    static value_type op(const value_type &l, const value_type &r) {
        if (l.invalid()) return r;
        if (r.invalid()) return l;
        return {l.l, r.r, l.v + r.v};
    }
};


// LeftHandSide
struct LazyEval {
    using value_type = mInt;

    static value_type op(const value_type &l, const value_type &r) {
        return l;
    }
};

struct RangeUpdateRMQ {
    using Monoid = RMQ;
    using Update = LazyEval;
    using value_type = typename Monoid::value_type;
    using update_type = typename Update::value_type;

    static value_type evaluate(const update_type &update, const value_type &r) {
        return {
                r.l,
                r.r,
                cumSum.sum(r.l, r.r) * update
        };
    }
};


void solve(long long N, long long Q, std::vector<long long> L, std::vector<long long> R, std::vector<long long> D) {
    mInt weight = 1;
    vector<mInt> weights(N);

    for (int i = N - 1; i >= 0; i--) {
        weights[i] = weight;
        weight *= 10;
    }
    vector<RangeData<mInt>> vs;
    for (int i = 0; i < N; i++) {
        vs.emplace_back(i, i+1, weights[i]);
    }
    SegmentTreeLazy<RangeUpdateRMQ> rmq(vs);


    cumSum = CumSum(weights);
    for (int i = 0; i < Q; i++) {
        L[i]--;
        rmq.update(L[i], R[i], D[i]);
        cout << (int) rmq.query(0, N).v << endl;
    }
}

int main() {
    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: 20572