#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353 ; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

template<typename T>
class lazy_segment_tree{
	int n;
	T fval;
	vector<T> dat, lazy;
	vector<bool> lazyFlag;
	vector<int> ten;
	vector<int> hoge;
	
public:
	
	lazy_segment_tree(){
		
	}
	
	lazy_segment_tree(int n_, T val){
		init(n_, val);
	}
	
	~lazy_segment_tree(){
		
	}
	
	void init(int n_, T val){
		fval = val;
		
		n = 1;
		
		while(n < n_) n *= 2;
		
		dat.resize(2 * n - 1);
		lazy.resize(2 * n - 1, fval);
		ten.resize(2 * n - 1, 10);
		hoge.resize(2 * n - 1, 1);
		lazyFlag.resize(2 * n - 1, false);
	
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval;
		
		for(int i = 2 * n - 2;i >= 0; i--) {
			if(i * 2 + 2 < ten.size()) {
				ten[i] = (ten[i * 2 + 2] * ten[i * 2 + 2]) % MOD;
			}
		}
		
		for(int i = 2 * n - 2;i >= 0; i--) {
			if(i * 2 + 2 < ten.size()) {
				hoge[i] = (ten[i * 2 + 2] * hoge[i * 2 + 2] + hoge[i * 2 + 2]) % MOD;
			}
		}
	}
	
	void eval(int k, int l, int r){
		// cout<<"eval"<<endl;
		if(lazyFlag[k]){
			// dat[k] = lazy[k] * (r - l);
			dat[k] = (lazy[k] * hoge[k]) % MOD;
			
			if(r - l > 1) {
				lazy[2*k+1] = lazy[2*k+2] = lazy[k];
				lazyFlag[2*k+1] = lazyFlag[2*k+2] = lazyFlag[k];
			}
			
			lazyFlag[k] = false;
		}
	}
	
	void update(int a, int b, T x, int k = 0, int l = 0, int r = -1, int z = 0){
		if(r < 0) r = n;
		eval(k, l, r);
		if(b <= l || r <= a) {return ;}
		if(a <= l && r <= b){
			lazy[k] = x;
			lazyFlag[k] = true;
			eval(k, l, r);
		} else {
			update(a, b, x, 2*k+1, l, (l+r)/2, z+1);
			update(a, b, x, 2*k+2, (l+r)/2, r, z+1);
			dat[k] = (dat[2*k+1] + dat[2*k+2]*ten[2*k+1]) % MOD;
		}
	}
	
	T query(int a, int b, int k = 0, int l = 0, int r = -1, int z = 0){
		if(r < 0) r = n;
		eval(k, l, r);
		if(r <= a || b <= l){
			return fval;
		}
		if(a <= l && r <= b){
			return dat[k];
		}else {
			T vl = query(a, b, k * 2 + 1, l, (l + r) / 2 , z+1);
			T vr = query(a, b, k * 2 + 2, (l + r) / 2, r, z+1);
			return (vl + vr*ten[2*k+1]) % MOD;
		}
	}
	
	int print(){
		cout<<"ten "<<endl;
		for(int i = 0, t = 0; i < ten.size(); i++){
			cout<<ten[i]<<" ";
			// int temp = i - t;
			// if(((temp-1)&temp) == 0) {
				// t = i+1;
			if(i == 0 || i == 2 || i == 6 || i == 14|| i == 30){
				cout<<" <> "<<i<<" "<<i*2+1<<" "<<n;
				if(i*2+1<n)cout<<"  "<<ten[i*2+1]<<endl;
				cout<<endl;
			}
		}
		cout<<endl;
		cout<<"hoge "<<endl;
		for(int i = 0; i < hoge.size(); i++){
			cout<<hoge[i]<<" ";
			// if(((i-1)&i) == 0) {
				// cout<<endl;
			// }
		if(i == 0 || i == 2 || i == 6 || i == 14 || i == 30){
				cout<<endl;
			}
		}
		cout<<endl;
		
		cout<<"dat "<<endl;
		for(int i = 0; i < dat.size(); i++){
			cout<<dat[i]<<" ";
			// if(((i-1)&i) == 0) {
				// cout<<endl;
			// }
			if(i == 0 || i == 2 || i == 6 || i == 14 || i == 30){
				cout<<endl;
			}
		}
		cout<<endl;
	}
};


signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, Q;
	lazy_segment_tree<long long> lseg;
	
	cin>>N>>Q;
	
	lseg.init(N+10, 0);
	
	for(int i = 0; i < N; i++){
		lseg.update(i, i + 1, 1);
	}
	
	// int res = lseg.query(0, N+1);
		
	// cout<<res<<"<> "<<endl;
	// lseg.print();
	
	for(int i = 0; i < Q; i++){
		int L, R, D;
		
		cin>>L>>R>>D;
		L--, R--;
		
		L = N - L - 1;
		R = N - R - 1;
		
		swap(L, R);
		
		lseg.update(L, R+1, D);
		
		int res = lseg.query(0, N+1);
		
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 19844