def modpow(a, n, mod)
  res = 1
  while n > 0
    res = res * a % mod if n & 1 != 0
    a = a * a % mod
    n >>= 1
  end
  res
end

n, q = gets.split(' ').map {|it| it.to_i}
s = '1' * n
z = 998244353
mod = s.to_i % z

q.times do
  l, r, d = gets.chomp.split(' ')
  l = l.to_i
  r = r.to_i
  right = modpow(10, n - r, z)
  a = s[(l-1)..(r-1)].to_i % z * right % z
  b = (d * (r - l + 1)).to_i % z * right % z
  mod = ((mod - a) % z + b) % z
  mod += z if mod < 0
  p mod
  s = s.chars.fill(d, (l-1)..(r-1)).join
end
