n,q = gets.chomp.split(' ').map(&:to_i)
arr = Array.new(n,1)
ans = []
q.times do
  l,r,d = gets.chomp.split(' ').map(&:to_i)
  arr[(l-1)..(r-1)] = Array.new((r-l+1),d)
  ans << arr.join.to_i % 998244353
end
ans.each do |a|
  puts a
end