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 JAVA):

Solution:
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    int n;
    long[] tree;
    int[] lazy;
    long[] sum10;
    int mod;

    private void push(int node, int a, int mid, int b) {
        tree[node * 2] = sumOfConsecutive(lazy[node], a, mid);
        tree[node  *2 + 1] = sumOfConsecutive(lazy[node], mid + 1, b);
        lazy[node * 2] = lazy[node];
        lazy[node * 2 + 1] = lazy[node];

        lazy[node] = 0;
    }

    private void insert(int from, int to, int num, int a, int b, int node) {
        if (from <= a && b <= to) {
            tree[node] = sumOfConsecutive(num, a, b);
            lazy[node] = num;
            return;
        }

        int mid = (a + b) / 2;
        if (lazy[node] != 0) push(node, a, mid, b);

        if (from <= mid) insert(from, to, num, a, mid, node * 2);
        if (to > mid) insert(from, to, num, mid + 1, b, node * 2 + 1);

        tree[node] = tree[node * 2 + 1] + tree[node * 2];
        tree[node] %= mod;
    }

    private long getSum(int from, int to, int a, int b, int node) {
        if (from <= a && b <= to) {
            return tree[node];
        }

        int mid = (a + b) / 2;
        if (lazy[node] != 0) push(node, a, mid, b);

        long sum = 0;
        if (from <= mid) sum += getSum(from, to, a, mid, node * 2);
        if (to > mid) sum += getSum(from, to, mid + 1, b, node  * 2 + 1);

        sum %= mod;
        return sum;
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    private void solve() throws IOException {
        /*
        StringBuilder commands = new StringBuilder();
        commands.append(8 + " " + 1000 + "\n");
        char[] seq = new char[8];
        Arrays.fill(seq, '1');
        ArrayList<String> results = new ArrayList<String>();
        for (int i = 0; i < 1000; i++) {
            Random r = new Random();
            int a = r.nextInt(8);
            int b = r.nextInt(8 - a);
            a++;
            b += a;
            int digit = r.nextInt(9) + 1;
            commands.append(a + " " + b + " " + digit);
            for (int j = a - 1; j <= b - 1; j++) {
                seq[j] = (char) (digit + '0');
            }
            results.add(new String(seq));
            commands.append("\n");
        }
        */
        //BufferedReader f = new BufferedReader(new StringReader(commands.toString()));
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        n = Integer.parseInt(tokenizer.nextToken());
        int q = Integer.parseInt(tokenizer.nextToken());

        sum10 = new long[n];
        long curr10 = 1;
        sum10[n - 1] = 1;
        mod = 998244353;
        for (int i = n - 2; i >= 0; i--) {
            curr10 *= 10;
            curr10 %= mod;
            sum10[i] += curr10;
            sum10[i] += sum10[i + 1];
            sum10[i] %= mod;
        }

        tree = new long[4 * n];
        lazy = new int[4 * n];
        insert(0, n - 1, 1, 0, n - 1, 1);

        //ArrayList<String> myResults = new ArrayList<String>();
        for (int q1 = 0; q1 < q; q1++) {
            tokenizer = new StringTokenizer(f.readLine());
            int a = Integer.parseInt(tokenizer.nextToken()) - 1;
            int b = Integer.parseInt(tokenizer.nextToken()) - 1;
            int num = Integer.parseInt(tokenizer.nextToken());
            insert(a, b, num, 0, n - 1, 1);
            //myResults.add(String.valueOf(getSum(0, n - 1, 0, n - 1, 1)));
            out.println(getSum(0, n - 1, 0, n - 1, 1));
        }

        out.close();
    }

    private long sumOfConsecutive(int digit, int a, int b) {
        long sum = sum10[a];
        if (b != n - 1) sum -= sum10[b + 1];
        sum *= digit;
        sum %= mod;
        sum += mod;
        sum %= mod;
        return sum;
    }
}