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 int long long
using namespace std;
const int N=2e5+5,MOD=998244353;
int n,q,l,r,v;
int ll[N<<2],rr[N<<2],num[N<<2],sum[10][N],add[N<<2],bin[N];
	
void build(int k,int l,int r)
{

	ll[k]=l; rr[k]=r;
	if (l==r)
	{
		num[k]=1;
		return;
	}
	int mid=l+r>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	num[k]=(num[k<<1]*bin[rr[k<<1|1]-ll[k<<1|1]+1]%MOD+num[k<<1|1])%MOD;	
}
inline void pushdown(int k)
{
	if (add[k])
	{
		num[k<<1]=sum[add[k]][rr[k<<1]-ll[k<<1]+1];
		num[k<<1|1]=sum[add[k]][rr[k<<1|1]-ll[k<<1|1]+1];
		add[k<<1]=add[k<<1|1]=add[k];
		add[k]=0;
	}
}
void change(int k,int l,int r,int qx,int qy,int v)
{
	if (qx<=l && r<=qy)
	{
		num[k]=sum[v][r-l+1];
		add[k]=v;
		return;
	}
	pushdown(k);
	int mid=l+r>>1;
	if (qx<=mid) change(k<<1,l,mid,qx,qy,v);
	if (mid<qy) change(k<<1|1,mid+1,r,qx,qy,v);
	num[k]=(num[k<<1]*bin[rr[k<<1|1]-ll[k<<1|1]+1]%MOD+num[k<<1|1])%MOD;
}
	
signed main(){
	scanf("%lld%lld",&n,&q);
	bin[0]=1;
	for (register int i=1; i<=n; ++i) bin[i]=bin[i-1]*10%MOD;
	for (register int i=1; i<=9; ++i)
	{
		sum[i][1]=i;
		for (register int j=2; j<=n; ++j) sum[i][j]=(sum[i][j-1]*10%MOD+i)%MOD;
	}
	build(1,1,n);
	for (register int i=1; i<=q; ++i) 
	{
		scanf("%lld%lld%lld",&l,&r,&v);
		change(1,1,n,l,r,v);
		printf("%lld\n",num[1]);
	}
return 0;	
}