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 LazyRangeSeg = {}
LazyRangeSeg.create = function(self, n)
  local stagenum, mul = 1, 1
  self.stage = {{0}}
  self.lazy_b = {{1}}
  self.lazy_c = {{0}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
    self.lazy_b[stagenum] = {}
    self.lazy_c[stagenum] = {}
    for i = 1, mul do
      self.stage[stagenum][i] = 0
      self.lazy_b[stagenum][i] = 1
      self.lazy_c[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 lzb_ip1, lzc_ip1 = self.lazy_b[i + 1], self.lazy_c[i + 1]
      local lz_b, lz_c = self.lazy_b[i][curidx], self.lazy_c[i][curidx]
      if 1 ~= lz_b or 0 ~= lz_c then
        self:resolveRange(i + 1, curidx * 2 - 1, lz_b, lz_c, true)
        self:resolveRange(i + 1, curidx * 2, lz_b, lz_c, true)
        lzb_ip1[curidx * 2 - 1] = bmul(lzb_ip1[curidx * 2 - 1], lz_b)
        lzb_ip1[curidx * 2] = bmul(lzb_ip1[curidx * 2], lz_b)
        lzc_ip1[curidx * 2 - 1] = badd(bmul(lz_b, lzc_ip1[curidx * 2 - 1]), lz_c)
        lzc_ip1[curidx * 2] = badd(bmul(lz_b, lzc_ip1[curidx * 2]), lz_c)
        self.lazy_b[i][curidx], self.lazy_c[i][curidx] = 1, 0
      end
    elseif p == right then
      break
    else
      assert(false)
    end
  end
end
LazyRangeSeg.resolveRange = function(self, stagepos, idx, vb, vc, shallow)
  local sz = bls(1, self.stagenum - stagepos)
  self.stage[stagepos][idx] = badd(bmul(self.stage[stagepos][idx], vb), bmul(vc, sz))
  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, vb, vc)
  if 1 < left then self:resolve(left - 1) end
  self:resolve(right)
  local stagenum = self.stagenum
  local n = #self.stage[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 idx = 1 + brs(left - 1, stagenum - stage)
    self:resolveRange(stage, idx, vb, vc)
    self.lazy_b[stage][idx] = bmul(self.lazy_b[stage][idx], vb)
    self.lazy_c[stage][idx] = badd(bmul(self.lazy_c[stage][idx], vb), vc)
    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", "*l")
local lzst = LazyRangeSeg.new(n)
local s = io.read()
do
  local i = 0
  for w in s:gmatch("%d+") do
    i = i + 1
    lzst:setRange(i, i, 1, tonumber(w))
  end
end
for iq = 1, q do
  local tp = io.read("*n")
  if tp == 0 then
    local l, r, b, c = io.read("*n", "*n", "*n", "*n")
    lzst:setRange(l + 1, r, b, c)
  else
    local l, r = io.read("*n", "*n")
    -- lzst:getRange(l + 1, r)
    print(lzst:getRange(l + 1, r))
  end
end
-- print(os.clock())
