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