#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010, mod = 998244353;
int n, q, rt[maxn], tot, lc[13000000], rc[13000000];
int mul[13000000], add[13000000], sum[13000000];
void pushup(int o) { sum[o] = (sum[lc[o]] + sum[rc[o]]) % mod; }
int Mul(int o, int l, int r, int v) {
  if (!o) {
    o = ++tot;
    mul[o] = 1;
  }
  mul[o] = 1LL * mul[o] * v % mod;
  add[o] = 1LL * add[o] * v % mod;
  sum[o] = 1LL * sum[o] * v % mod;
  return o;
}
int Add(int o, int l, int r, int v) {
  if (!o) {
    o = ++tot;
    mul[o] = 1;
  }
  add[o] = (add[o] + v) % mod;
  sum[o] = (sum[o] + 1LL * v * (r - l + 1) % mod) % mod;
  return o;
}
void pushdown(int o, int l, int r) {
  int mid = (l + r) >> 1;
  lc[o] = Mul(lc[o], l, mid, mul[o]);
  rc[o] = Mul(rc[o], mid + 1, r, mul[o]);
  mul[o] = 1;
  lc[o] = Add(lc[o], l, mid, add[o]);
  rc[o] = Add(rc[o], mid + 1, r, add[o]);
  add[o] = 0;
}
void update(int o, int p, int l, int r, int x, int y) {
  if (x <= l && r <= y) {
    if (sum[p] == (r - l + 1)) {
      Mul(o, l, r, 2);
      return;
    }
    if (sum[p] == 0) {
      Add(p, l, r, 1);
      Add(o, l, r, 1);
      return;
    }
  }
  pushdown(o, l, r);
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  if (x <= mid) update(lc[o], lc[p], l, mid, x, y);
  if (y > mid) update(rc[o], rc[p], mid + 1, r, x, y);
  pushup(o);
  pushup(p);
}
int query(int o, int l, int r, int x, int y) {
  if (x <= l && r <= y) return sum[o];
  pushdown(o, l, r);
  int mid = (l + r) >> 1, res = 0;
  if (x <= mid) res = (res + query(lc[o], l, mid, x, y)) % mod;
  if (y > mid) res = (res + query(rc[o], mid + 1, r, x, y)) % mod;
  return res;
}
int main() {
  scanf("%d%d", &n, &q);
  tot = n + 1;
  for (int i = 1; i <= n; i++) rt[i] = i + 1;
  for (int i = 1; i <= n + 1; i++) mul[i] = 1;
  while (q--) {
    int opt, l, r, x;
    scanf("%d%d%d", &opt, &l, &r);
    if (opt == 1) {
      scanf("%d", &x);
      update(1, rt[x], 1, n, l, r);
    } else
      printf("%d\n", query(1, 1, n, l, r));
  }
  return 0;
}
