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
int n,q;
int mi[200001],sum[200001];
int summ[1000001],s,t,lazi[1000001];
using namespace std;

void bui(int k,int l,int r)
{
	if(l==r)
	{
		summ[k]=mi[l];
		return;
	}
	int mid=(l+r)>>1;
	bui(k<<1,l,mid),bui(k<<1|1,mid+1,r);
	summ[k]=(summ[k<<1]+summ[k<<1|1])%998244353; 
	return ;
}

void add(int k,int l,int r,int v)
{
	lazi[k]=v;
	summ[k]=(((sum[r]-sum[l-1]+998244353)%998244353)*v)%998244353;
	return;
}

void pushd(int k,int l,int r,int mid)
{
	if(lazi[k]==0)
		return;
	add(k<<1,l,mid,lazi[k]);
	add(k<<1|1,mid+1,r,lazi[k]);
	lazi[k]=0;
	return;
}

void updata(int k,int l,int r,int v)
{
	if(l>=s&&r<=t)
	{
		add(k,l,r,v);
		return;
	}
	int mid=(l+r)>>1;
	pushd(k,l,r,mid);
	if(s<=mid) updata(k<<1,l,mid,v);
	if(mid<t) 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;
	}
	bui(1,1,n);  
	int num;
	for(int i=1;i<=q;i++)
	{
		int ss,tt;
		scanf("%lld%lld%lld",&ss,&tt,&num);
		s=n-tt+1,t=n-ss+1;
		updata(1,1,n,num);
		printf("%lld\n",summ[1]);
	}

	return 0;
 }