# 整数の入力
n, q = gets.chomp.split(" ").map(&:to_i)

word = 1.to_s * n 
# word = 12345678.to_s
# puts word

root = 998244353


q.times do
  l, r, d = gets.chomp.split(" ").map(&:to_i)
  f = word[0, (l-1)]
  mid = d.to_s * (r - l + 1)
  l = word[r, n-r+1]
  # puts "<" + f 
  # puts "<" + mid 
  # puts "<" + l 
  word = f + mid + l 
  # puts word
  puts word.to_i % root
end