# 整数の入力                                                                                                                            
n, q = gets.chomp.split(" ").map(&:to_i)                                                                                                
                                                                                                                                        
word = 1.to_s * n                                                                                                                       
# puts word                                                                                                                             
                                                                                                                                        
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-1]                                                                                                                      
  # puts "<" + f                                                                                                                        
  # puts "<" + mid                                                                                                                      
  # puts "<" + l                                                                                                                        
  word = f + mid + l                                                                                                                    
  puts word.to_i % 998244353                                                                                                            
end     