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:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define int long long
const int MOD=998244353;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
int blo[450],wa[450],s[223456],K[450];

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,q;cin>>n>>q;
  for(int i=0,tmp=0;i<n;i++){
    s[i]=1;
    tmp=((tmp*10)+1)%MOD;
    if(i%450==449||i==n-1){
      blo[i/450]=tmp;
      tmp=0;
    }
  }
  K[0]=1;
  for(int i=1;i<450;i++)K[i]=(K[i-1]*10)%MOD;
  const int A=pw(10,450);
  const int C=(A-1)*pw(9,MOD-2)%MOD;
  while(q--){
    int l,r,d;cin>>l>>r>>d;
    l=n-l+1,r=n-r;swap(l,r);
    int res=0;
    for(int i=0,CC=1;i<450;i++){
      if(l<=i*450&&(i+1)*450<=r){
        wa[i]=d;
        blo[i]=C*d;
      }
      else if((i*450<=l&&l<(i+1)*450)||(i*450<r&&r<=(i+1)*450)){
        int tmp=0;
        for(int j=i*450,t=0;j<(i+1)*450;j++,t++){
          if(wa[i])s[j]=wa[i];
          if(l<=j&&j<r)s[j]=d;
          tmp=(tmp+s[j]*K[t])%MOD;
        }
        blo[i]=tmp;
        wa[i]=0;
      }
      res=(res+blo[i]*CC)%MOD;
      (CC*=A)%=MOD;
    }
    cout<<res<<"\n";
  }
}