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<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;

const int maxn = 2e6 + 10;
typedef long long int ll;
ll mod = 998244353;
ll s[maxn * 4];
ll ans[maxn * 4],add[maxn * 4];

#define mid (l + r) / 2
#define lson (rt * 2)
#define rson (rt * 2) + 1

void pushdown(int rt,int l,int r){
    if(add[rt]){
        ans[lson] = (s[mid] - s[l - 1] + mod) % mod * add[rt] % mod;
        ans[rson] = (s[r] - s[mid] + mod) % mod * add[rt] % mod;
        add[lson] = add[rson] = add[rt];
        add[rt] = 0;
    }
}
void update(int rt,int ql,int qr,int l,int r,int v){
    if(l >= ql && r <= qr){
        ans[rt] = (s[r] - s[l - 1] + mod) % mod * v % mod;
        add[rt] = v;
        return ;
    }
    pushdown(rt,l,r);
    if(ql <= mid)update(lson,ql,qr,l,mid,v);
    if(qr > mid)update(rson,ql,qr,mid + 1,r,v);
    ans[rt] = (ans[lson] + ans[rson])% mod;
}
void solved(){
    int n,q;cin>>n>>q;
    s[n] = 1;
    for(int i = n - 1;i >= 1; i--)
        s[i] = ((s[i + 1] % mod) * 10) % mod;
    for(int i = 1; i <= n; i++)
        s[i] = ((s[i - 1] % mod) + s[i]) % mod;
    for(int i = 1; i <= n; i++)
        update(1,i,i,1,n,1);
    while(q--){
        int l,r,v;cin>>l>>r>>v;
        update(1,l,r,1,n,v);    
        printf("%lld\n",ans[1]);
    }
}
int main(){
    solved();
    return 0;
}