local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift

local mod = 998244353
local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end
local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local pows = {1}
local powsum = {1}
for i = 2, 300010 do
  pows[i] = (pows[i - 1] * 10) % mod
  powsum[i] = (pows[i] + powsum[i - 1]) % mod
end
print(powsum[2])

local LazyRangeSeg = {}
LazyRangeSeg.create = function(self, n)
  local stagenum, mul = 1, 1
  self.stage = {{powsum[n]}}
  self.lazy = {{1}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
    self.lazy[stagenum] = {}
    for i = 1, mul do
      self.stage[stagenum][i] = 0
      self.lazy[stagenum][i] = 0
    end
  end
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  self.stagenum = stagenum
end
LazyRangeSeg.resolve = function(self, right)
  local stagenum = self.stagenum
  local offset = 0
  for i = 1, stagenum - 1 do
    local p = offset + bls(1, stagenum - i)
    if p < right then
      offset = p
      p = p + bls(1, stagenum - i)
    end
    if right < p then
      local curidx = brs(p, stagenum - i)
      local incval = self.lazy[i][curidx]
      if 0 < incval then
        --
        local v1 = powsum[p]
        local v2 = 0 == offset and 0 or powsum[offset]
        local mid = powsum[offset + bls(1, stagenum - i - 1)]
        self:resolveRange(i + 1, curidx * 2 - 1, bmul(incval, bsub(mid, v2)), true)
        self:resolveRange(i + 1, curidx * 2, bmul(incval, bsub(v1, mid)), true)
        self.lazy[i + 1][curidx * 2 - 1] = incval
        self.lazy[i + 1][curidx * 2] = incval
        self.lazy[i][curidx] = 0
      end
    elseif p == right then
      break
    else
      assert(false)
    end
  end
end
LazyRangeSeg.resolveRange = function(self, stagepos, idx, value, shallow)
  self.stage[stagepos][idx] = value
  if shallow then return end
  for i = stagepos - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = badd(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
LazyRangeSeg.getRange = function(self, left, right)
  if 1 < left then self:resolve(left - 1) end
  self:resolve(right)
  local stagenum = self.stagenum
  local ret = 0
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = badd(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
LazyRangeSeg.setRange = function(self, left, right, value)
  if 1 < left then self:resolve(left - 1) end
  self:resolve(right)
  local stagenum = self.stagenum
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    local len = right - left + 1
    local idx = 1 + brs(left - 1, stagenum - stage)
    local v1 = powsum[left + sz - 1]
    local v2 = left == 1 and 0 or powsum[left - 1]
    local v = bmul(value, bsub(v1, v2))
    self:resolveRange(stage, idx, v)
    self.lazy[stage][idx] = value
    left = left + sz
  end
end
LazyRangeSeg.new = function(n)
  local obj = {}
  setmetatable(obj, {__index = LazyRangeSeg})
  obj:create(n)
  return obj
end

local n, q = io.read("*n", "*n")
local lzst = LazyRangeSeg.new(n)

for iq = 1, q do
  local l, r, d = io.read("*n", "*n", "*n")
  l, r = n + 1 - r, n + 1 - l
  lzst:setRange(l, r, d)
  print(lzst:getRange(1, n))
end
