using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int64;

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class Solver
{
    N[] ten;
    N[] one;

    public void Solve()
    {
        int n = (int)rn, q = (int)rn;
        ten = new N[n + 1];
        one = new N[n + 1];
        ten[0] = 1;
        one[0] = 0;
        for(int i = 0; i < n; i++)
        {
            ten[i + 1] = (ten[i] * 10) % mod;
            one[i + 1] = (one[i] * 10 + 1) % mod;
        }
        S unit = new S(1,1);
        S[] v = Enumerable.Repeat(unit, n).ToArray();
        Func<S, S, S> op = (x, y) => new S(x.len + y.len, (x.val * ten[y.len] + y.val) % mod);
        Func<int, S, S> mapping = (f, s) => f == 0 ? s : new S(s.len, one[s.len] * f % mod);
        Func<int, int, int> composition = (l, r) => (l == 0) ? r : l;
        S e = new S(0, 0);
        var seg = new LazySegTree<S, int>(v, op, e, mapping, composition, 0);

        int L, R, D;
        for (int i = 0; i < q; i++)
        {
            L = (int)rn;
            R = (int)rn;
            D = (int)rn;
            seg.apply(L - 1, R, D);
            Write(seg.prod(0, n).val);
        }
    }

    public class S
    {
        public int len { get; set; }
        public N val { get; set; }
        public S(int len, N val)
        {
            this.len = len;
            this.val = val;
        }
    }

    public class LazySegTree<S, F>
    {
        int _n, log, size;
        S _e;
        Func<S, S, S> _op;
        Func<F, S, S> _mapping;
        Func<F, F, F> _composition;
        F _id;
        S[] d;
        F[] lz;
        public LazySegTree(S[] v, Func<S, S, S> op, S e, Func<F, S, S> mapping, Func<F, F, F> composition, F id)
        {
            _op = op;
            _mapping = mapping;
            _composition = composition;
            _id = id;
            _e = e;
            _n = v.Length;
            log = 0;
            while (1 << log < _n) { log++; }
            size = 1 << log;
            d = Enumerable.Repeat(_e, 2 * size).ToArray();
            lz = Enumerable.Repeat(_id, size).ToArray();
            for (int i = 0; i < _n; i++) { d[size + i] = v[i]; }
            for (int i = size - 1; i > 0; i--) { update(i); }
        }
        public void set(int p, S x)
        {
            p += size;
            for (int i = log; i >= 1; i--) push(p >> i);
            d[p] = x;
            for (int i = 1; i <= log; i++) update(p >> i);
        }
        public S get(int p)
        {
            p += size;
            for (int i = log; i >= 1; i--) push(p >> i);
            return d[p];
        }
        public S prod(int l, int r)
        {
            if (l == r) return _e;
            l += size;
            r += size;
            for (int i = log; i >= 1; i--)
            {
                if (((l >> i) << i) != l) push(l >> i);
                if (((r >> i) << i) != r) push(r >> i);
            }
            S sml = _e, smr = _e;
            while (l < r)
            {
                if ((l & 1) == 1) sml = _op(sml, d[l++]);
                if ((r & 1) == 1) smr = _op(d[--r], smr);
                l >>= 1;
                r >>= 1;
            }

            return _op(sml, smr);
        }
        public S all_prod() { return d[1]; }
        public void apply(int p, F f)
        {
            p += size;
            for (int i = log; i >= 1; i--) push(p >> i);
            d[p] = _mapping(f, d[p]);
            for (int i = 1; i <= log; i++) update(p >> i);
        }
        public void apply(int l, int r, F f)
        {
            if (l == r) return;
            l += size;
            r += size;
            for (int i = log; i >= 1; i--)
            {
                if (((l >> i) << i) != l) push(l >> i);
                if (((r >> i) << i) != r) push((r - 1) >> i);
            }
            {
                int l2 = l, r2 = r;
                while (l < r)
                {
                    if ((l & 1) == 1) all_apply(l++, f);
                    if ((r & 1) == 1) all_apply(--r, f);
                    l >>= 1;
                    r >>= 1;
                }
                l = l2;
                r = r2;
            }

            for (int i = 1; i <= log; i++)
            {
                if (((l >> i) << i) != l) update(l >> i);
                if (((r >> i) << i) != r) update((r - 1) >> i);
            }
        }

        void update(int i) { d[i] = _op(d[2 * i], d[2 * i + 1]); }
        void all_apply(int k, F f)
        {
            d[k] = _mapping(f, d[k]);
            if (k < size) lz[k] = _composition(f, lz[k]);
        }
        void push(int k)
        {
            all_apply(2 * k, lz[k]);
            all_apply(2 * k + 1, lz[k]);
            lz[k] = _id;
        }
    }

    const N mod = 998244353;
    N Gcd(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++) { p = Gcd(p, n[i]); } return p; }
    N Gcd(N a, N b) { return (a == 0) ? b : Gcd(b % a, a); }

    N rn { get { return sc.Integer(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    void Write<T>(T t) { Console.WriteLine(t.ToString()); }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}



public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public N Integer()
    {
        N ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public double Double() { return double.Parse(Scan()); }
}


Measured memory_bytes: 79160