/**
 * \author KienNguyen246
 * \date 26/09/2020
 */

///😐

 ///----------------🤔🤔🤔 -----------------///

/**< 🤣🤣🤣 */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int maxn = 8e5 + 5;
const int mod = 998244353;
const int infi = (2e9 + 69);
const ll infy = (2e16 + 69);
const int base = 311;
const ll MM = 7ll * mod * mod;
const int addition = 1e5;
const db eps = 1e-8;
const string numd[10] = {"1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011"};
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const double pi = 3.14159265358980;
const string P1 = "T";
const string P2 = "HL";
const string spmcode = "My power does not end. Ask for aid and you will receive it.\n";

template <typename Num> void maximize(Num &x, Num y) {x = mx(x, y);}
template <typename Num> void minimize(Num &x, Num y) {x = min(x, y);}
void exit_with_runtime() {db x = 1.0 * clock() / CLOCKS_PER_SEC; cerr << "\n\n---------------------\nTime elapsed: " << x << " s.\n\n"; exit(0);}
void decorate() {cerr << "KienNguyen246\n"; chrono:: system_clock::time_point today = chrono::system_clock::now(); time_t tt = chrono::system_clock::to_time_t(today); cerr << ctime(&tt); cerr << "\nProcessing...\n\n";}

///Multiple tests?
#define MUL_TEST 0

/**< 🤣🤣🤣 */

//bool Palin(string s) {string r = s; reverse(whole(r)); return (r == s);}

/* 🙃🙃🙃 */
int n, q, len[maxn];
long long p10[maxn], p11[maxn], tree[maxn], val[maxn];
/* 🙃🙃🙃 */

void Init(int nod, int l, int r)
{
    len[nod] = r - l + 1;
    if (l == r)
    {
        tree[nod] = 1;
        return;
    }
    int mid = (l + r) / 2;
    Init(nod * 2, l, mid);
    Init(nod * 2 + 1, mid + 1, r);
    tree[nod] = p10[r - mid] * tree[nod * 2] % mod;
    tree[nod] = (tree[nod] + tree[nod * 2 + 1]) % mod;
}

void Push(int nod)
{
    if (len[nod] % 2 == 0) tree[nod * 2] = tree[nod * 2 + 1]  = val[nod] * p11[len[nod] / 2] % mod;
    else
    {
        tree[nod * 2] = val[nod] * p11[len[nod] / 2 + 1] % mod;
        tree[nod * 2 + 1] = val[nod] * p11[len[nod] / 2] % mod;
    }
    val[nod * 2] = val[nod * 2 + 1] = val[nod];
    val[nod] = 0;
}

void Upd(int nod, int l, int r, int u, int v, int w)
{
    if (u > r || v < l) return;
    if (l >= u && r <= v)
    {
        val[nod] = w;
        tree[nod] = w * p11[r - l + 1] % mod;
        return;
    }
    if (val[nod]) Push(nod);
    int mid = (l + r) / 2;
    Upd(nod * 2, l, mid, u, v, w);
    Upd(nod * 2 + 1, mid + 1, r, u, v, w);
    tree[nod] = p10[r - mid] * tree[nod * 2] % mod;
    tree[nod] = (tree[nod] + tree[nod * 2 + 1]) % mod;
}

//My power does not end. Ask for aid and you will receive it.
int Main_Process()
{
    cin >> n >> q;
    p10[0] = 1;
    p11[0] = 0;
    for (int i = 1; i <= n; i ++)
    {
        p10[i] = p10[i - 1] * 10 % mod;
        p11[i] =(p11[i - 1] * 10 + 1) % mod;
    }
    Init(1, 1, n);
    while (q--)
    {
        int u, v, w;
        cin >> u >> v >> w;
        Upd(1, 1, n, u, v, w);
        cout << tree[1] << "\n";
    }
    return 0;
}

/**< 😂😂😂 */
int main()
{
    /**< Main preprocessing begin */
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    decorate();

    #ifndef ONLINE_JUDGE
        freopen(".inp", "r", stdin);
//        freopen(".out", "w", stdout);
    #endif
    /**< Main preprocessing end */
    /*😍😍😍*/
    int test = 1;
    cerr << spmcode << "\n";
    #if MUL_TEST
        cin >> test;
    #endif
    while (test --) Main_Process();
    exit_with_runtime();
}
/**< 😂😂😂 */
///😂😂😂😂😂😂😂😂🌚🔥😂😂😂😂🌚🔥😂😂🔥😂😂😂🔥😂😂😂🔥😂💯💯💯💯💩🐸🔥😂🔥😂🔥💩🔥🔥😂🌚💯🐸💯💩🐸🔥🔥💞🔥💩💩💩💞😂😂😂😂😂😂😂💞💞😂😂😂💞🔥🔥💞💯💩💞💯💞😂😂😂💞💩💩💩💩💩💩💞💩💩💩💩💩💩💩💩💞🔥🔥😂💞🔥😂😂💞


Measured memory_bytes: 17264