#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long mod = 998244353;
set<pair<int, int> > s[N];
long long add[N << 2], mul[N << 2], sum[N << 2];
long long ans;
void pushup(int rt) { sum[rt] = (sum[rt << 1] + sum[rt << 1 | 1]) % mod; }
void build(int rt, int l, int r) {
  sum[rt] = add[rt] = 0;
  mul[rt] = 1;
  if (l < r) {
    int mid = (l + r) >> 1;
    build(rt << 1, l, mid);
    build(rt << 1 | 1, mid + 1, r);
    pushup(rt);
  }
}
void pushdown(int rt, int len) {
  add[rt << 1] = add[rt] + add[rt << 1] * mul[rt] % mod;
  add[rt << 1] %= mod;
  add[rt << 1 | 1] = add[rt] + add[rt << 1 | 1] * mul[rt] % mod;
  add[rt << 1 | 1] %= mod;
  sum[rt << 1] =
      add[rt] * (len - (len >> 1)) % mod + sum[rt << 1] * mul[rt] % mod;
  sum[rt << 1] %= mod;
  sum[rt << 1 | 1] =
      add[rt] * (len >> 1) % mod + sum[rt << 1 | 1] * mul[rt] % mod;
  mul[rt << 1] *= mul[rt];
  mul[rt << 1] %= mod;
  mul[rt << 1 | 1] *= mul[rt];
  mul[rt << 1 | 1] %= mod;
  mul[rt] = 1;
  add[rt] = 0;
}
void update(int rt, int l, int r, int ql, int qr, int v, int ty) {
  if (l >= ql && r <= qr) {
    if (ty == 2) {
      mul[rt] *= v;
      mul[rt] %= mod;
      add[rt] *= v;
      add[rt] %= mod;
      sum[rt] *= v;
      sum[rt] %= mod;
    } else {
      add[rt] += v;
      add[rt] %= mod;
      sum[rt] += 1LL * v * (r - l + 1);
      sum[rt] %= mod;
    }
    return;
  }
  pushdown(rt, r - l + 1);
  int mid = (l + r) >> 1;
  if (ql <= mid) update(rt << 1, l, mid, ql, qr, v, ty);
  if (qr > mid) update(rt << 1 | 1, mid + 1, r, ql, qr, v, ty);
  pushup(rt);
}
void query(int rt, int l, int r, int ql, int qr) {
  if (l >= ql && r <= qr) {
    ans += sum[rt];
    ans %= mod;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(rt, r - l + 1);
  if (ql <= mid) query(rt << 1, l, mid, ql, qr);
  if (qr > mid) query(rt << 1 | 1, mid + 1, r, ql, qr);
}
int main() {
  int n, q, ty, l, r, x, recl, recr, pos;
  set<pair<int, int> >::iterator it;
  set<pair<int, int> >::iterator it2;
  set<pair<int, int> >::iterator itr;
  scanf("%d %d", &n, &q);
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &ty);
    if (ty == 1) {
      scanf("%d %d %d", &l, &r, &x);
      if (s[x].empty()) {
        s[x].insert({l, r});
        update(1, 1, n, l, r, 1, 1);
        continue;
      }
      it = s[x].lower_bound({l + 1, 0});
      if (it != s[x].begin()) {
        it--;
        if (it->second >= r) {
          update(1, 1, n, l, r, 2, 2);
          continue;
        } else if (it->second >= l - 1) {
          if (it->second >= l) update(1, 1, n, l, it->second, 2, 2);
          pos = it->second;
          recl = it->first;
          it2 = it;
          it++;
          s[x].erase(it2);
        } else {
          recl = l;
          pos = l - 1;
          it++;
        }
      } else {
        recl = l;
        pos = l - 1;
      }
      itr = s[x].lower_bound({r + 1, 0});
      recr = r;
      while (it != itr) {
        if (it->first - pos >= 2) update(1, 1, n, pos + 1, it->first - 1, 1, 1);
        update(1, 1, n, it->first, min(it->second, r), 2, 2);
        recr = max(recr, it->second);
        pos = it->second;
        it2 = it;
        it++;
        s[x].erase(it2);
      }
      if (r - pos >= 1) update(1, 1, n, pos + 1, r, 1, 1);
      if (itr != s[x].end() && it->first == r + 1) {
        recr = itr->second;
        s[x].erase(itr);
      }
      s[x].insert({recl, recr});
    } else {
      scanf("%d %d", &l, &r);
      ans = 0;
      query(1, 1, n, l, r);
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
