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>
using namespace std;
#define lc (x<<1)  
#define rc (x<<1|1) 
#define mid (l+r)/2   
int const mod=998244353;  
int const N=2e5+10;  
int n,q,pw[N],v[N][10],t[N<<2],tag[N<<2];  
void build(int x,int l,int r){
	if(l==r) {
		t[x]=1LL*pw[n-r] % mod;  
		return ; 
	}  
	build(lc,l,mid); 
	build(rc,mid+1,r);  
	t[x]=(t[lc]+t[rc])%mod;  
}  
void pushdown(int x,int l,int r){
	if(!tag[x]) return ;  
	if(l==r) return ;  
	tag[lc]=tag[rc]=tag[x]; 
	t[lc]=(v[l][tag[x]]-v[mid+1][tag[x]]) % mod;  
	t[rc]=(v[mid+1][tag[x]]-v[r+1][tag[x]])  % mod;  
	t[lc]=(t[lc]+mod)% mod; 
	t[rc]=(t[rc]+mod)% mod;  
	tag[x]=0;  
}  
void update(int x,int l,int r,int ll,int rr,int d){ 
	pushdown(x,l,r); 
	if(ll<=l && r<=rr) { 
		tag[x]=d;  
		t[x]=(v[l][d]-v[r+1][d])  % mod;  
		t[x]=(t[x]+mod)%mod;  
		//cout<<x<<" "<<l<<" "<<r<<" "<<t[x]<<endl; 
		return ;  
	}  
	if(ll<=mid) update(lc,l,mid,ll,rr,d);  
	if(rr>mid) update(rc,mid+1,r,ll,rr,d);  
	t[x]=(t[lc]+t[rc])%mod;  
}   
int main(){
	ios::sync_with_stdio(false); 
	cin.tie(0);  
	cin>>n>>q; 
	pw[0]=1; 
	for(int i=1;i<=n;i++) 
		pw[i]=1LL*pw[i-1]*10% mod;  
	for(int i=1;i<10;i++)
		for(int j=n;j>=1;j--) 
			v[j][i]=(v[j+1][i]+1LL*i*pw[n-j]) % mod ; 
	build(1,1,n);  
	//cout<<t[1]<<endl; 
	while (q--){
		int l,r,d; 
		cin>>l>>r>>d; 
//		cout<<"nima"<<l<<" "<<r<<" "<<d<<endl;  
		update(1,1,n,l,r,d); 
		cout<<t[1]<<endl;  
	}  
	return 0; 
}