#define _CRT_SECURE_NO_WARNINGS

//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb emplace_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 3e5 + 50, oo = 2e18 + 500;
const int mod = 998244353;
//const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-6, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
vvi g;
//vi rg[N];
vi visit(N, 0);

vi deg;
vi calc;

struct segtree
{
	struct node
	{
		int set;
		int sum;
	};

	int N;
	vector<node> tree;
	int NO_OPERATION = -oo;
	int NEUTRAL_ELEMENT = 0;

	void init(int n)
	{
		N = 1;
		while (N < n) N <<= 1;
		tree.assign(N << 1, { 0, 0 });
	}

	void build(int n)
	{
		init(n);
	}

	void push(int v, int lx, int rx)
	{
		if (tree[v].set == NO_OPERATION || rx == lx)
		{
			return;
		}

		tree[v << 1].set = tree[v].set;
		tree[v << 1 | 1].set = tree[v].set;
		int m = (rx + lx) >> 1;
		tree[v << 1].sum = tree[v].set * calc[m - lx + 1] % mod;
		tree[v << 1 | 1].sum = tree[v].set * calc[rx - m] % mod;
		tree[v].set = NO_OPERATION;
	}

	void set(int v, int lx, int rx, int l, int r, int val)
	{
		if (l > r)
			return;

		push(v, lx, rx);

		if (lx == l && rx == r)
		{
			tree[v].set = val;
			tree[v].sum = val * calc[r - l + 1] % mod;
			return;
		}

		int m = (lx + rx) >> 1;
		set(v << 1, lx, m, l, min(r, m), val);
		set(v << 1 | 1, m + 1, rx, max(m + 1, l), r, val);
		tree[v].sum = (tree[v << 1].sum*deg[rx - m] % mod + tree[v << 1 | 1].sum) % mod;
	}

	void set(int l, int r, int val)
	{
		set(1, 0, N - 1, l, r, val);
	}

	int get(int v, int lx, int rx, int l, int r)
	{
		if (l > r)
			return NEUTRAL_ELEMENT;

		push(v, lx, rx);

		if (lx == l && rx == r)
		{
			return tree[v].sum;
		}

		int m = (lx + rx) >> 1;
		int g1 = get(v << 1, lx, m, l, min(r, m));
		int g2 = get(v << 1 | 1, m + 1, rx, max(m + 1, l), r);
		return (g1 * (r - max(m + 1, l) + 1 >= 0 ? deg[r - max(m + 1, l) + 1] : 1) % mod
			+ g2) % mod;
	}

	int get(int l, int r)
	{
		return get(1, 0, N - 1, l, r);
	}
};

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("rblock.in", "r", stdin);
	//freopen("rblock.out", "w", stdout);

	cin >> n >> k;

	deg.assign(n, 1);
	calc.assign(n + 1, 0);
	for (int i = 1; i < n; i++)
	{
		deg[i] = deg[i - 1] * 10 % mod;
		calc[i] = (calc[i - 1] * 10 + 1) % mod;
	}

	segtree st;
	st.build(n);
	st.set(0, n - 1, 1);

	for (int i = 0; i < k; i++)
	{
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;

		st.set(l, r, d);
		cout << st.get(0, n - 1) << endl;
	}
}



Measured memory_bytes: 16500