use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

const MOD: i64 = 998244353;

struct Ones {
    total: Vec<i64>,
}

impl Ones {
    fn new(size: usize) -> Self {
        let mut total = vec![1; size];
        for i in 1..size {
            total[i] = (total[i - 1] * 10 + 1) % MOD;
        }

        Self { total }
    }

    fn num(&self, digit: i64, left: usize, right: usize) -> i64 {
        let mut ones = self.total[right];
        if left > 0 {
            ones = (ones + MOD - self.total[left - 1]) % MOD;
        }
        (ones * digit) % MOD
    }
}

struct SegTree {
    sum: Vec<i64>,
    lazy: Vec<i64>,
    ones: Ones,
    size: usize,
}

impl SegTree {
    fn new(size: usize) -> Self {
        let nodes = 4 * size + 10;
        Self {
            sum: vec![0; nodes],
            lazy: vec![0; nodes],
            ones: Ones::new(size + 1),
            size,
        }
    }

    fn update(&mut self, digit: i64, left: usize, right: usize) {
        self.up(0, 0, self.size - 1, digit, left, right)
    }

    fn up(&mut self, node: usize, l: usize, r: usize, digit: i64, left: usize, right: usize) {
        self.propagate(node, l, r);

        if left <= l && r <= right {
            self.lazy[node] = digit;
            self.propagate(node, l, r);
            return;
        }

        let m = l + (r - l) / 2;
        if left <= m {
            self.up(self.left(node), l, m, digit, left, right);
        }
        if m < right {
            self.up(self.right(node), m + 1, r, digit, left, right);
        }

        self.propagate(self.left(node), l, m);
        self.propagate(self.right(node), m + 1, r);

        self.sum[node] =
            (self.sum[self.left(node)] + self.sum[self.right(node)]) % MOD;
    }

    fn get(&mut self, left: usize, right: usize) -> i64 {
        self.find(0, 0, self.size - 1, left, right)
    }

    fn find(&mut self, node: usize, l: usize, r: usize, left: usize, right: usize) -> i64 {
        self.propagate(node, l, r);

        if left <= l && r <= right {
            return self.sum[node];
        }

        let m = l + (r - l) / 2;
        let mut res = 0;

        if left <= m {
            res = (res + self.find(self.left(node), l, m, left, right)) % MOD;
        }
        if m < right {
            res = (res + self.find(self.right(node), m + 1, r, left, right)) % MOD;
        }
        res
    }

    fn propagate(&mut self, node: usize, left: usize, right: usize) {
        let l = self.left(node);
        if l < self.sum.len() && self.lazy[node] > 0 {
            self.lazy[l] = self.lazy[node];
        }

        let r = self.right(node);
        if r < self.sum.len() && self.lazy[node] > 0 {
            self.lazy[r] = self.lazy[node];
        }

        if self.lazy[node] > 0 {
            self.sum[node] = self.ones.num(self.lazy[node], left, right);
        }
        self.lazy[node] = 0;
    }

    fn left(&self, node: usize) -> usize {
        2 * node + 1
    }

    fn right(&self, node: usize) -> usize {
        2 * node + 2
    }
}

fn main() {
    let mut reader = TokenReader::new();
    let n = reader.next();
    let q = reader.next();

    let mut num = SegTree::new(n);
    num.update(1, 0, n - 1);

    for _ in 0..q {
        let r = n - reader.next::<usize>();
        let l = n - reader.next::<usize>();
        let d = reader.next();

        num.update(d, l, r);
        println!("{}", num.get(0, n - 1));
    }
}


Measured memory_bytes: 14428