#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

vector<long long int>one;
vector<long long int>ten;

class Add_Segment_Tree {
	vector<long long int>by;
	vector<long long int>modi;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	void Modify(int a, int b, long long int num, int place) {
		if (l[place] >= a && r[place] <= b) {
			modi[place] = num;
			v[place] = num * by[place] % MOD;
			return;
		}
		if (l[place] > b || r[place] < a)return;
		if (modi[place] != LLONG_MAX) {
		//	cout << "-------------------" << a << " " << b << " " << num << " " << place << endl;
		//	cout << modi[place] << endl;
			modi[place * 2] = modi[place * 2 + 1] = modi[place];
			v[place * 2] = modi[place * 2] * by[place * 2] % MOD;
			v[place * 2 + 1] = modi[place * 2 + 1] * by[place * 2 + 1] % MOD;
			modi[place] = LLONG_MAX;
		}
		Modify(a, b, num, place * 2);
		Modify(a, b, num, place * 2 + 1);
		v[place] = v[place * 2] + v[place * 2 + 1];
		v[place] %= MOD;
		return;
	}
	void Sum(int a, int b, int place) {
		if (l[place] >= a && r[place] <= b) {
			if (modi[place] != LLONG_MAX) {
				if (place * 2 < v.size()) {
					modi[place * 2] = modi[place * 2 + 1] = modi[place];
				}
				modi[place] = LLONG_MAX;
			}
			ret += v[place];
			ret %= MOD;
			return;
		}
		if (l[place]>b || r[place]<a) return;
		if (modi[place] != LLONG_MAX) {
			modi[place * 2] = modi[place * 2 + 1] = modi[place];
			modi[place] = LLONG_MAX;
		}
		Sum(a, b, place * 2);
		Sum(a, b, place * 2 + 1);
		v[place] = v[place * 2] + v[place * 2 + 1];
		v[place] %= MOD;
		return;
	}
public:
	vector<long long int>v;
	Add_Segment_Tree(int n) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		v.resize(num, 0);
		by.resize(num);
		modi.resize(num, LLONG_MAX);
		n -= 2;
		Left(1);
		Right(1);
		for (int i = 1; i < by.size(); i++) {
			r[i] = min(r[i], n);
			if (l[i] <= r[i]) {
				by[i] = ten[n - r[i]] * one[r[i] - l[i]] % MOD;
	//			cout << i << " " << by[i] << endl;
			}
		}
	}
	void Modify(int a, int b, long long int num) {
		Modify(a, b, num, 1);
	}
	long long int Sum(int a, int b) {
		ret = 0;
		Sum(a, b, 1);
		return ret;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> K;
	one.resize(N * 2 + 1, 1);
	ten.resize(N * 2 + 1, 1);
	for (int i = 1; i <= N * 2; i++) {
		one[i] = one[i - 1] * 10 + 1;
		one[i] %= MOD;
		ten[i] = ten[i - 1] * 10 % MOD;
	}
	Add_Segment_Tree sg(N);
	sg.Modify(0, N - 1, 1);
//	cout << sg.Sum(0, N - 1) << endl;
//	for (int i = 0; i < sg.v.size(); i++) {
//		cout << i << " " << sg.v[i] << endl;
//	}
	while (K--) {
		cin >> L >> R >> M;
		L--, R--;
		sg.Modify(L, R, M);
		cout << sg.Sum(0, N - 1) << endl;
	//	for (int i = 0; i < sg.v.size(); i++) {
	//		cout << i << " " << sg.v[i] << endl;
	//	}
	}
}

Measured memory_bytes: 25884