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>

using namespace std;
typedef long long ll;
const int N=2e5+10;
const int mod=998244353;
ll sum[N<<2],lazy[N<<2],n;
ll p[15][N];
void push_down(int rt,int l,int r){
    if(lazy[rt]){
        int mid=l+r>>1;
        sum[rt<<1]=p[lazy[rt]][mid-l+1]*p[10][n-mid]%mod;
        sum[rt<<1|1]=p[lazy[rt]][r-mid]*p[10][n-r]%mod;
        lazy[rt<<1]=lazy[rt<<1|1]=lazy[rt];
        lazy[rt]=0;
    }
}
void build(int l,int r,int rt){
    if(l==r){sum[rt]=p[10][n-r];return;};
    int mid=l+r>>1;
    build(l,mid,rt<<1);build(mid+1,r,rt<<1|1);
    sum[rt]=(sum[rt<<1]+sum[rt<<1|1])%mod;
}
void update(int l,int r,int L,int R,int val,int rt){
    if(L<=l&&r<=R){
        sum[rt]=p[val][r-l+1]*p[10][n-r]%mod;
        lazy[rt]=val;
        return ;
    }
    push_down(rt,l,r);
    int mid=l+r>>1;
    if(L<=mid)update(l,mid,L,R,val,rt<<1);
    if(mid<R)update(mid+1,r,L,R,val,rt<<1|1);
    sum[rt]=(sum[rt<<1]+sum[rt<<1|1])%mod;
}
void init(int n){
    for(int i=1;i<=9;i++){
        for(int j=1;j<=n;j++)
            p[i][j]=(p[i][j-1]*10+i)%mod;
    }
    p[10][0]=1;
    for(int i=1;i<=n;i++)p[10][i]=p[10][i-1]*10%mod;
}
int main(){
    init(200000);int m;
    scanf("%d %d",&n,&m);
    build(1,n,1);
    while(m--){
        int l,r,val;scanf("%d %d %d",&l,&r,&val);
        update(1,n,l,r,val,1);
        printf("%lld\n",sum[1]);
    }
}