#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::fmt::Write as _Write;
use std::i64;
use std::io::{stdin, BufWriter, Read, Write};
use std::usize;

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, q: usize);
    let mut s = BTreeSet::<(usize, usize, i64)>::new();
    let mut rm = vec![];
    let mut add = vec![];
    let mut ones = vec![0; n];
    let m = 998244353;
    let mut c = 1;
    for i in (0..n).rev() {
        ones[i] = c;
        c *= 10;
        c += 1;
        c %= m;
    }
    let mut ret = ones[0];
    let fx = |l: usize, r: usize, d: i64| ((ones[l] - if r < n { ones[r] } else { 0 }) * d) % m;
    s.insert((0, n, 1));
    for _ in 0..q {
        parse!(it, l: u1, r: usize, d: i64);
        rm.clear();
        add.clear();
        add.push((l, r, d));
        for &(li, ri, di) in s.range((l, 0, 0)..(r, !0, !0)) {
            rm.push((li, ri, di));
            if ri > r {
                add.push((r, ri, di));
            }
        }

        for &(li, ri, di) in &rm {
            ret -= fx(li, ri, di);
            ret %= m;
            s.remove(&(li, ri, di));
        }
        rm.clear();

        if let Some(&(li, ri, z)) = s.range(..(r, r, !0)).rev().next() {
            if ri > l {
                rm.push((li, ri, z));
                add.push((li, l, z));
            }
            if ri > r {
                add.push((r, ri, z));
            }
        }
        for &(li, ri, di) in &rm {
            ret -= fx(li, ri, di);
            ret %= m;
            s.remove(&(li, ri, di));
        }
        for &(li, ri, di) in &add {
            ret += fx(li, ri, di);
            ret %= m;
            s.insert((li, ri, di));
        }
        // eprintln!("rm  {:?}", rm); // DEBUG
        // eprintln!("add {:?}", add); // DEBUG
        // eprintln!("s   {:?}", s); // DEBUG
        ret %= m;
        if ret < 0 {
            ret += m;
        }
        println!("{:?}", ret); // DEBUG
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}
trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}


Measured memory_bytes: 19296