#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <int mod>
class Modint {
    static_assert(mod > 0, "Modulus must be positive");

public:
    static constexpr int get_mod() noexcept { return mod; }

    constexpr Modint(long long y = 0) noexcept : x(y >= 0 ? y % mod : (y % mod + mod) % mod) {}

    constexpr int value() const noexcept { return x; }

    constexpr Modint& operator+=(const Modint& p) noexcept { if ((x += p.x) >= mod) x -= mod; return *this; }
    constexpr Modint& operator-=(const Modint& p) noexcept { if ((x += mod - p.x) >= mod) x -= mod; return *this; }
    constexpr Modint& operator*=(const Modint& p) noexcept { x = static_cast<int>(1LL * x * p.x % mod); return *this; }
    constexpr Modint& operator/=(const Modint& p) noexcept { *this *= p.inv(); return *this; }

    constexpr Modint operator-() const noexcept { return Modint(-x); }

    constexpr Modint operator+(const Modint& p) const noexcept { return Modint(*this) += p; }
    constexpr Modint operator-(const Modint& p) const noexcept { return Modint(*this) -= p; }
    constexpr Modint operator*(const Modint& p) const noexcept { return Modint(*this) *= p; }
    constexpr Modint operator/(const Modint& p) const noexcept { return Modint(*this) /= p; }

    constexpr bool operator==(const Modint& p) const noexcept { return x == p.x; }
    constexpr bool operator!=(const Modint& p) const noexcept { return x != p.x; }

    constexpr Modint inv() const noexcept {
        int a = x, b = mod, u = 1, v = 0;
        while (b > 0) {
            int t = a / b;
            std::swap(a -= t * b, b);
            std::swap(u -= t * v, v);
        }
        return Modint(u);
    }

    constexpr Modint pow(long long n) const noexcept {
        Modint ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend std::ostream &operator<<(std::ostream& os, const Modint& p) {
        return os << p.x;
    }

    friend std::istream &operator>>(std::istream& is, Modint& a) {
        long long t;
        is >> t;
        a = Modint<mod>(t);
        return is;
    }

private:
    int x;
};

template <typename M, typename O, typename M::T (*act)(typename M::T, typename O::T)>
class LazySegmentTree {
    using T = typename M::T;
    using E = typename O::T;

public:
    LazySegmentTree() = default;
    explicit LazySegmentTree(int n) : LazySegmentTree(std::vector<T>(n, M::id)) {}
    explicit LazySegmentTree(const std::vector<T>& v) {
        size = 1;
        height = 0;
        while (size < (int) v.size()) size <<= 1, ++height;
        node.resize(2 * size, M::id);
        lazy.resize(2 * size, O::id);
        std::copy(v.begin(), v.end(), node.begin() + size);
        for (int i = size - 1; i > 0; --i) node[i] = M::op(node[2 * i], node[2 * i + 1]);
    }

    T operator[](int k) {
        return fold(k, k + 1);
    }

    void update(int l, int r, const E& x) { update(l, r, x, 1, 0, size); }

    T fold(int l, int r) { return fold(l, r, 1, 0, size); }

private:
    int size, height;
    std::vector<T> node;
    std::vector<E> lazy;

    void push(int k) {
        if (lazy[k] == O::id) return;
        if (k < size) {
            lazy[2 * k] = O::op(lazy[2 * k], lazy[k]);
            lazy[2 * k + 1] = O::op(lazy[2 * k + 1], lazy[k]);
        }
        node[k] = act(node[k], lazy[k]);
        lazy[k] = O::id;
    }

    void update(int a, int b, const E& x, int k, int l, int r) {
        push(k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] = O::op(lazy[k], x);
            push(k);
            return;
        }
        int m = (l + r) / 2;
        update(a, b, x, 2 * k, l, m);
        update(a, b, x, 2 * k + 1, m, r);
        node[k] = M::op(node[2 * k], node[2 * k + 1]);
    }

    T fold(int a, int b, int k, int l, int r) {
        push(k);
        if (r <= a || b <= l) return M::id;
        if (a <= l && r <= b) return node[k];
        int m = (l + r) / 2;
        return M::op(fold(a, b, 2 * k, l, m),
                     fold(a, b, 2 * k + 1, m, r));
    }
};

using mint = Modint<998244353>;

vector<mint> pow10;
vector<mint> cum;

struct Monoid {
    using T = pair<mint, int>;
    inline static const T id = {0, 1};
    static T op(T a, T b) {
        return {a.first * pow10[a.second] + b.first, a.second + b.second};
    }
};

struct UpdateMonoid {
    using T = int;
    inline static const T id = -1;
    static T op(T a, T b) {
        return b;
    }
};

pair<mint, int> act(pair<mint, int> a, int b) {
    return {cum[a.second - 1] * b, a.second};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, Q;
    cin >> N >> Q;
    int n = 1;
    while (n < N) n <<= 1;
    pow10.resize(n + 1);
    pow10[0] = 1;
    for (int i = 1; i <= n; i++) pow10[i] = pow10[i - 1] * 10;
    cum.resize(n + 1);
    cum[0] = 1;
    for (int i = 1; i <= n; i++) cum[i] = cum[i-1] + pow10[i];
    LazySegmentTree<Monoid, UpdateMonoid, act> st(n);
    st.update(n - N, n, 1);
    for (int i = 0; i < Q; ++i) {
        int L, R, D;
        cin >> L >> R >> D;
        L--;
        st.update(n - N + L, n - N + R, D);
        cout << st.fold(0, n).first << "\n";
    }
}

Measured memory_bytes: 13512