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 <stdio.h>
#define MN 200000
const int mod=998244353;

int n,q;

int m10[MN+5];

struct node{
	int sum,tag,bsc;
}T[MN*4+5];

void build(int k,int l,int r){
	T[k].tag = 0;
	if(l==r){
		T[k].sum = 1;
		T[k].bsc = T[k].sum;
		return;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	T[k].sum = (1ll*T[k<<1].sum*m10[r-mid]+T[k<<1|1].sum)%mod;
	T[k].bsc = T[k].sum;
}

void pushtag(int k,int w){
	T[k].sum = (1ll*T[k].bsc*w)%mod;
	T[k].tag = w;
}

void pushdown(int k){
	if(T[k].tag){
		pushtag(k<<1,T[k].tag);
		pushtag(k<<1|1,T[k].tag);
		T[k].tag = 0;
	}
}

void modify(int k,int l,int r,int L,int R,int w){
	if(l==L&&r==R){
		pushtag(k,w);
		return;
	}
	int mid=(l+r)>>1;
	pushdown(k);
	if(R<=mid) modify(k<<1,l,mid,L,R,w);
	else if(L>mid) modify(k<<1|1,mid+1,r,L,R,w);
	else modify(k<<1,l,mid,L,mid,w),modify(k<<1|1,mid+1,r,mid+1,R,w);
	T[k].sum = (1ll*T[k<<1].sum*m10[r-mid]+T[k<<1|1].sum)%mod;
}

int main(){
	scanf("%d%d",&n,&q);
	m10[0] = 1;
	for(int i=1;i<=n;i++)
		m10[i] = (10ll*m10[i-1])%mod;
	build(1,1,n);
	for(int l,r,d;q--;){
		scanf("%d%d%d",&l,&r,&d);
		modify(1,1,n,l,r,d);
		printf("%d\n",T[1].sum);
	}
}