program r20926e
 
implicit none
integer(16) :: n, q, l, r, snum, i, j
character(len=200000) :: s
character(len=1) :: d

read *, n, q

do i = 1, n
 s(i:i) = '1'
end do

do i= 1, q
 read *, l, r, d
 do j = l, r
  s(j:j) = d
 end do

 s = trim(s)
 
 print *, s
 stop
 
 read(s,*) snum
 
 print *, mod(snum, 998244353)
 
end do

end program r20926e