Problem: You have a string S of length N. Initially, all characters in S are `1`s.

You will perform queries Q times. In the i-th query, you are given two integers L_i, R_i and a character D_i (which is a digit). Then, you must replace all characters from the L_i-th to the R_i-th (inclusive) with D_i.

After each query, read the string S as a decimal integer, and print its value modulo 998,244,353.

Constraints

* 1 \leq N, Q \leq 200,000
* 1 \leq L_i \leq R_i \leq N
* 1 \leq D_i \leq 9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N Q
L_1 R_1 D_1
:
L_Q R_Q D_Q


Output

Print Q lines. In the i-th line print the value of S after the i-th query, modulo 998,244,353.

Examples

Input

8 5
3 6 2
1 4 7
3 8 3
2 2 2
4 5 1


Output

11222211
77772211
77333333
72333333
72311333


Input

200000 1
123 456 7


Output

641437905

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define M 998244353

int mm[200000], sm[200001];
void init(){
	int c=1;
	sm[0]=0;
	rep(i, 200000){
		mm[i]=c;
		sm[i+1]=(sm[i]+c)%M;
		c=((ll)c*10)%M;
	}
}

int main(){
	init();
	int n, q;
	cin>>n>>q;

	set<P> ps;
	vector<int> md(n);
	int ans=0;

	auto add=[&](int l, int r, int d){
		ans=(ans+(ll)(d+M) *sm[r-l+1]%M *mm[l]%M)%M;
	};
	auto ins=[&](int x, int lr, int d){
		ps.insert(make_pair(x, lr));
		md[x]=d;
	};

	add(0, n-1, 1);
	ins(0, 0, 1);
	ins(n-1, 1, 1);

	rep(_, q){
		int tl, tr, d;
		cin>>tl>>tr>>d;
		int l=n-tr;
		int r=n-tl;

		auto it=ps.lower_bound(make_pair(l, 0));
		int kl=-1, kr;
		vector<set<P>::iterator> dl;
		while(it!= ps.end() && (it->first) <=r){
			if(it->second == 0){
				kl= it->first;
			}
			else{
				kr=it->first;
				if(kl== -1){//right cut
					kl=l;
					ins(l-1, 1, md[kr]);
				}
				add(kl, kr, -md[kr]);
				kl= -1;
			}
			dl.push_back(it);
			it++;
		}
		if(kl != -1){//left cut
			kr=r;
			add(kl, kr, -md[kl]);
			ins(r+1, 0, md[kl]);
		}
		for(auto it : dl) ps.erase(it);

		it=ps.lower_bound(make_pair(r+1, 0));
		if(it!=ps.end() && it->second==1){//middle cut
			int kd= md[it->first];
			add(l, r, -kd);
			ins(l-1, 1, kd);
			ins(r+1, 0, kd);
		}

		add(l, r, d);
		ins(l, 0, d);
		ins(r, 1, d);

		cout<<ans<<endl;
	}
	return 0;
}