function main(input) {
  input = input.split("\n").map(v => v.split(" "));
  const [n, q] = input[0].map(v => +v);
  input.shift();

  const mod = 998244353;
  const str = (new Array(n)).fill(1);
  
  input.map(value => {
    const [l, r, d] = [(value[0] - 1), (value[1] - 1), +value[2]];

    let num = 0;
    for (let i = 0; i < n; i++) {
      if (l <= i && i <= r) {
        str[i] = d;
      }
      num = (num * 10 + str[i]) % mod;
    }
    console.log(num);
  });  
}
// 魔法
main(require("fs").readFileSync("/dev/stdin", "utf8"));
