#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, p = 998244353, inv2 = (p + 1) >> 1;
int n, m;
map<int, int> ot[N];
namespace Seg {
int sm[N << 2], tgp[N << 2], tgm[N << 2], si[N << 2];
inline void Pre(int v = 1, int l = 1, int r = n) {
  tgm[v] = 1, tgp[v] = 0;
  sm[v] = 0;
  si[v] = r - l + 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  Pre(v << 1, l, mid);
  Pre(v << 1 | 1, mid + 1, r);
}
inline void SetAdd(int v, int x) {
  sm[v] = (sm[v] + 1ll * x * si[v]) % p;
  tgp[v] = (tgp[v] + x) % p;
}
inline void SetMul(int v, int x) {
  sm[v] = 1ll * sm[v] * x % p;
  tgp[v] = 1ll * tgp[v] * x % p;
  tgm[v] = 1ll * tgm[v] * x % p;
}
inline void PushDown(int v) {
  if (tgm[v] != 1) {
    SetMul(v << 1, tgm[v]);
    SetMul(v << 1 | 1, tgm[v]);
    tgm[v] = 1;
  }
  if (tgp[v]) {
    SetAdd(v << 1, tgp[v]);
    SetAdd(v << 1 | 1, tgp[v]);
    tgp[v] = 0;
  }
}
inline void PushUp(int v) { sm[v] = (sm[v << 1] + sm[v << 1 | 1]) % p; }
inline void Add(int x, int y, int v = 1, int l = 1, int r = n) {
  if (x > r || y < l) return;
  if (x <= l && r <= y) return SetAdd(v, 1), void();
  PushDown(v);
  int mid = (l + r) >> 1;
  Add(x, y, v << 1, l, mid);
  Add(x, y, v << 1 | 1, mid + 1, r);
  PushUp(v);
}
inline void Mul(int x, int y, int v = 1, int l = 1, int r = n) {
  if (x > r || y < l) return;
  if (x <= l && r <= y) return SetMul(v, 2), void();
  PushDown(v);
  int mid = (l + r) >> 1;
  Mul(x, y, v << 1, l, mid);
  Mul(x, y, v << 1 | 1, mid + 1, r);
  PushUp(v);
}
inline int Ask(int x, int y, int v = 1, int l = 1, int r = n) {
  if (x > r || y < l) return 0;
  if (x <= l && r <= y) return sm[v];
  PushDown(v);
  int mid = (l + r) >> 1;
  return (Ask(x, y, v << 1, l, mid) + Ask(x, y, v << 1 | 1, mid + 1, r)) % p;
}
}  // namespace Seg
inline void Solve(map<int, int> &mp, int x, int y) {
  map<int, int>::iterator xit = --mp.upper_bound(x);
  if (xit->second < x) ++xit;
  map<int, int>::iterator yit = mp.upper_bound(y);
  if (xit == yit) {
    Seg::Add(x, y);
    mp[x] = y;
    return;
  }
  int la = x;
  for (map<int, int>::iterator it = xit; it != yit; ++it) {
    if (la < it->first) Seg::Add(la, it->first - 1), la = it->first;
    Seg::Mul(la, min(it->second, y));
    la = it->second + 1;
    y = max(y, it->second);
  }
  if (la <= y) Seg::Add(la, y);
  if (xit->first < x) {
    xit->second = max(xit->second, y);
    mp.erase(++xit, yit);
  } else {
    mp.erase(xit, yit);
    mp[x] = y;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    ot[i][0] = 0;
    ot[i][n + 1] = n + 1;
  }
  Seg::Pre();
  while (m--) {
    int opt, x, y, z;
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d%d%d", &x, &y, &z);
      Solve(ot[z], x, y);
    } else {
      scanf("%d%d", &x, &y);
      printf("%d\n", Seg::Ask(x, y));
    }
  }
  return 0;
}
