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<iostream>
#include<cstdio>
#include<cmath>
#define int long long
using namespace std;
int n,q;
int mi[200010],sum[200010];
int summ[1000010];
int la[1000010];
int x,y,z;
void build(int k,int l,int r)
{
	if(l==r)
	{
		summ[k]=mi[l]%998244353;
		return ;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	summ[k]=(summ[k<<1]+summ[k<<1|1])%998244353;
}
void add(int k,int l,int r,int v)
{
	la[k]=v;
	summ[k]=((sum[r]-sum[l-1]+998244353)%998244353*v)%998244353;
}
void pushdown(int k,int l,int r,int mid)
{
	if(la[k]==0)
		return ;
	add(k<<1,l,mid,la[k]);
	add(k<<1|1,mid+1,r,la[k]);
	la[k]=0;
	return;
}
void updata(int k,int l,int r,int v)//y左，x右 
{
	if(l>=y&&r<=x)
	{
		add(k,l,r,v);
		return; 
	}
	int mid=(l+r)>>1;
	pushdown(k,l,r,mid);
	if(y<=mid)
		updata(k<<1,l,mid,v);
	if(mid+1<=x)
		updata(k<<1|1,mid+1,r,v);
	summ[k]=(summ[k<<1]+summ[k<<1|1])%998244353;
}
signed main()
{
	scanf("%lld%lld",&n,&q);
	mi[1]=1;
	sum[1]=1;
	for(int i=2;i<=n;i++)
	{
		mi[i]=(mi[i-1]*10)%998244353;
		sum[i]=(mi[i]+sum[i-1])%998244353;
	}
	build(1,1,n);
	for(int i=1;i<=q;i++)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		y=n-y+1;
		x=n-x+1;
		updata(1,1,n,z);
		printf("%lld\n",summ[1]);
	}	
}