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

q.times do
  l, r, d = gets.chomp.split(' ')
  l = l.to_i
  r = r.to_i
  a = s[(l - 1)..(r - 1)]
  b = d * (r - l + 1)
  mod = mod - BigDecimal(a + '0' * (n - r)) % z + BigDecimal(b + '0' * (n - r)) % z
  mod += z if mod < 0
  p mod.to_i
  s = (l > 1 ? s[0..(l - 2)] : '') + b + (r < n ? s[r..(n - 1)] : '')
end
