n,q = gets.split.map(&:to_i)
l = Array.new(n+1)
r = Array.new(n+1)
d = Array.new(n+1)
ans = (10**(n+1)-1)/9
for j in 1..q
	l[j],r[j],d[j] = gets.split.map(&:to_i)
	a=10**(n-r[j]+1)
	ans = (ans/10**(n-l[j]+2))*(10**(n-l[j]+2))+ans%a
	ans += d[j]*(((10**(n-l[j]+2)-1)/9)-(10**(n-r[j]+1)-1)/9)
	puts ans%998244353
end	