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 lc id<<1
#define rc id<<1|1
#define int long long
using namespace std;
const int maxn=400005,mod=998244353;
struct tree {
	int l,r,sum,tag;
} t[maxn*4];
int f[maxn],n,m,ans;
void fac() {
	f[n]=1;
	for(register int i=n-1; i>=1; i--) {
		f[i]=f[i+1]*10ll%mod;
	}
	for(register int i=1; i<=n; i++) {
		f[i]=(f[i]+f[i-1])%mod;
	}
}
void build(int id,int l,int r) {
	t[id].l=l,t[id].r=r;
	if(l==r) {
		return;
	}
	int mid=(l+r)/2;
	build(lc,l,mid);
	build(rc,mid+1,r);
}
void pushdown(int id) {
	if(t[id].tag) {
		t[lc].tag=t[rc].tag=t[id].tag;
		t[lc].sum=(f[t[lc].r]-f[t[lc].l-1]+mod)%mod*t[id].tag%mod;
		t[rc].sum=(f[t[rc].r]-f[t[rc].l-1]+mod)%mod*t[id].tag%mod;
		t[id].tag=0;
	}
}
void pushup(int id) {
	t[id].sum=(t[lc].sum+t[rc].sum)%mod;
}
void add(int id,int l,int r,int v) {
	if(t[id].l>r||t[id].r<l) {
		return;
	}
	if(t[id].l>=l&&t[id].r<=r) {
		//cout<<'*'<<l<<' '<<r<<' '<<t[id].sum<<endl;
		t[id].sum=(f[t[id].r]-f[t[id].l-1]+mod)%mod*v%mod;
		t[id].tag=v;
		return;
	}
	pushdown(id);
	add(lc,l,r,v);
	add(rc,l,r,v);
	pushup(id);
}
signed main() {
	int x,y,z;
	scanf("%lld%lld",&n,&m);
	fac();
	build(1,1,n);
	add(1,1,n,1);
	//cout<<ans<<endl;
	for(register int i=1; i<=m; i++) {
		scanf("%lld%lld%lld",&x,&y,&z);
		add(1,x,y,z);
		printf("%lld\n",t[1].sum%mod);
	}
	return 0;
}