#include <iostream>
#include <vector>
using namespace std;
const int MOD = 998244353;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long pow_mod(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = (res * a) % MOD;
		n >>= 1;
		a = (a * a) % MOD;
	}
	return res;
}

long long inverse_mod(long long a) {
	long long b = MOD, x = 1, u = 0;
	while (b != 0) {
		long long r = a % b, q = a / b;
		a = b; b = r;
		int nu = x - q*u;
		x = u; u = nu;
	}
	x %= MOD;
	if (x < 0) x += MOD;
	return x;
}

template<class M, class L> struct LazyPropagationSegmentTree
{
	int n;
	int size;
	int log_n;
	vector<M> data;
	vector<L> lazy;
	const function<M(M, M)> f_m;
	const M e_m;
	const function<L(L, L)> f_l;
	const L e_l;
	const function<M(M, L)> f;
	const function<L(L, int)> p;

	LazyPropagationSegmentTree(int n, function<M(M, M)> f_m, M e_m, function<L(L, L)> f_l, L e_l, function<M(M, L)> f, function<L(L, int)> p) : n(n), f_m(f_m), e_m(e_m), f_l(f_l), e_l(e_l), f(f), p(p) {
		size = 1;
		log_n = 0;
		while (size < n) size <<= 1, log_n++;
		data.assign(size * 2, e_m);
		lazy.assign(size * 2, e_l);
	}

	void init(const vector<M> &init_vals) {
		data.assign(size * 2, e_m);
		for (int i = 0; i < init_vals.size(); i++) data[size+i] = init_vals[i];
		for (int i = size-1; i > 0; i--) data[i] = f_m(data[2*i], data[2*i+1]);
	}

	void eval(int k, int len) {
		if (lazy[k] == e_l) return;
		if (k < size) {
			lazy[2*k] = f_l(lazy[2*k], lazy[k]);
			lazy[2*k + 1] = f_l(lazy[2*k + 1], lazy[k]);
		}
		data[k] = f(data[k], p(lazy[k], len));
		lazy[k] = e_l;
	}

	void update(int l, int r, L l_prop) {
		update_aux(l, r, l_prop, 1, 0, size);
	}

	void update_aux(int l, int r, L l_prop, int k, int k_l, int k_r) {
		eval(k, k_r - k_l);
		if (r <= k_l || k_r <= l) return;
		else if (l <= k_l && k_r <= r) {
			lazy[k] = f_l(lazy[k], l_prop);
			eval(k, k_r - k_l);
		} else {
			update_aux(l, r, l_prop, 2*k, k_l, (k_l + k_r) / 2);
			update_aux(l, r, l_prop, 2*k + 1, (k_l + k_r) / 2, k_r);
			data[k] = f_m(data[2*k], data[2*k + 1]);
		}
	}

	M query_all() {
		eval(1, size);
		return data[1];
	}

	M query(int l, int r) {
		return query_aux(l, r, 1, 0, size);
	}

	M query(int idx) {
		return query_aux(idx, idx+1, 1, 0, size);
	}

	M query_aux(int l, int r, int k, int k_l, int k_r) {
		eval(k, k_r - k_l);
		if (r <= k_l || k_r <= l) return e_m;
		else if (l <= k_l && k_r <= r) return data[k];
		else {
			M vl = query_aux(l, r, k*2, k_l, (k_l + k_r) / 2);
			M vr = query_aux(l, r, k*2 + 1, (k_l + k_r) / 2, k_r);
			return f_m(vl, vr);
		}
	}

	int find_max_right(int l, const function<bool(M)> &g) {
		if (l == n) return n;
		l += size;
		M s = e_m;
		for (int i = log_n, len = size; i >= 0; i--, len >>= 1) eval(l>>i, len);
		int len = 1;
		while (true) {
			while (l % 2 == 0) l >>= 1, len <<= 1;
			eval(l, len);
			if (!g(f_m(s, data[l]))) break;
			s = f_m(s, data[l]);
			l++;
			if ((l & -l) == l) return n;
		}
		while (l < size) {
			l = 2 * l, len >>= 1;
			eval(l, len);
			if (g(f_m(s, data[l]))) {
				s = f_m(s, data[l]);
				l++;
			}
		}
		return l - size;
	}

	int find_min_left(int r, const function<bool(M)> &g) {
		if (r == 0) return 0;
		r += size;
		M s = e_m;
		for (int i = log_n, len = size; i >= 0; i--, len >>= 1) eval((r-1)>>i, len);
		int len = 1;
		while (true) {
			r--;
			while (r > 1 && (r % 2)) r >>= 1, len <<= 1;
			eval(r, len);
			if (!g(f_m(data[r], s))) break;
			s = f_m(data[r], s);
			if ((r & -r) == r) return 0;
		}
		while (r < size) {
			r = 2 * r + 1, len >>= 1;
			eval(r, len);
			if (g(f_m(data[r], s))) {
				s = f_m(data[r], s);
				r--;
			}
		}
		return r + 1 - size;
	}

	void eval_all() {
		int len = size, j = 2;
		for (int i = 1; i < 2*size; i++) {
			if (i == j) j *= 2, len /= 2;
			eval(i, len);
		}
	}

	M val(int idx) {
		return data[size + idx];
	}

	vector<M> val_vec() {
		vector<M> res(n);
		for (int i = 0; i < n; i++) res[i] = data[size+i];
		return res;
	}
};

int main() {
	int n, Q;
	cin >> n >> Q;

	struct M
	{
		long long val, l;
	};
	using L = long long;
	M e_m = {0, 0};
	L e_l = 0;
	auto f_m = [&](M m1, M m2) -> M {
		if (m1.l == 0) return m2;
		if (m2.l == 0) return m1;
		return {(pow_mod(10, m2.l) * m1.val % MOD + m2.val) % MOD, m1.l + m2.l};
	};
	auto f_l = [&](L l1, L l2) -> L {
		return l2;
	};
	auto f = [&](M m, L l) -> M {
		return {l * mod(pow_mod(10, m.l) - 1) % MOD * inverse_mod(9) % MOD, m.l};
	};
	auto p = [&](L l, int len) -> L {
		return l;
	};
	LazyPropagationSegmentTree<M, L> st(n, f_m, e_m, f_l, e_l, f, p);
	vector<M> ini(n, M{1, 1});
	st.init(ini);
	
	for (int q = 0; q < Q; q++) {
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		l--;
		st.update(l, r, d);
		long long ans = st.query_all().val;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 18188