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>

using namespace std;

const int kMaxN = 200001;
const int kM = 998244353;

struct V {
  long long d, v;
} v[kMaxN * 4];

long long f[10][kMaxN];
int n, q, l, r, d;

void C(int i, int ml, int mr, int d) {
  v[i].d = d;
  v[i].v = f[d][mr - ml + 1];
}

void U(int i, int ml, int mr, int nl, int nr, int d) {
  if (ml == nl && mr == nr) {
    C(i, ml, mr, d);
    return;
  }
  int m = (ml + mr) >> 1;
  if (v[i].d) {
    C(i * 2, ml, m, v[i].d);
    C(i * 2 + 1, m + 1, mr, v[i].d);
    v[i].d = 0;
  }
  if (nl <= m) {
    U(i * 2, ml, m, nl, min(nr, m), d);
  }
  if (nr > m) {
    U(i * 2 + 1, m + 1, mr, max(nl, m + 1), nr, d);
  }
  v[i].v = (v[i * 2].v * f[0][mr - m] + v[i * 2 + 1].v) % kM;
}

int main() {
  cin >> n >> q;
  f[0][0] = 1;
  for (int i = 0; i <= 9; i++) {
    for (int j = 1; j <= n; j++) {
      f[i][j] = (f[i][j - 1] * 10 + i) % kM;
    }
  }
  U(1, 1, n, 1, n, 1);
  for (int i = 1; i <= q; i++) {
    cin >> l >> r >> d;
    U(1, 1, n, l, r, d);
    cout << v[1].v << endl;
  }
  return 0;
}