#include <bits/stdc++.h>
using namespace std;
const int M = 1e7, N = 2e5 + 5, P = 998244353, Ni = 499122177;
int n, q, ch[M][2], si[M], rt[N], cnt, t1[N << 2], t2[N << 2], sum[N << 2];
void set_t1(int x, int t) {
  sum[x] = 1ll * sum[x] * t % P;
  t1[x] = 1ll * t1[x] * t % P;
  t2[x] = 1ll * t2[x] * t % P;
}
void set_t2(int x, int t, int l, int r) {
  sum[x] = (1ll * t * (r - l + 1) + sum[x]) % P;
  t2[x] = (t2[x] + t) % P;
}
void pushdown(int x, int l, int r) {
  if (t1[x] != 1) {
    set_t1((x << 1), t1[x]);
    set_t1((x << 1 | 1), t1[x]);
    t1[x] = 1;
  }
  if (t2[x]) {
    int mid = (l + r) >> 1;
    set_t2((x << 1), t2[x], l, mid);
    set_t2((x << 1 | 1), t2[x], mid + 1, r);
    t2[x] = 0;
  }
}
int Query(int x, int l, int r, int ql, int qr) {
  if (l == ql && r == qr) return sum[x];
  int mid = (l + r) >> 1;
  pushdown(x, l, r);
  if (qr <= mid) return Query((x << 1), l, mid, ql, qr);
  if (ql > mid) return Query((x << 1 | 1), mid + 1, r, ql, qr);
  return (Query((x << 1), l, mid, ql, mid) +
          Query((x << 1 | 1), mid + 1, r, mid + 1, qr)) %
         P;
}
void Modify(int x, int l, int r, int ql, int qr) {
  if (l == ql && r == qr) {
    set_t1(x, 2);
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(x, l, r);
  if (qr <= mid)
    Modify((x << 1), l, mid, ql, qr);
  else if (ql > mid)
    Modify((x << 1 | 1), mid + 1, r, ql, qr);
  else
    Modify((x << 1), l, mid, ql, mid),
        Modify((x << 1 | 1), mid + 1, r, mid + 1, qr);
  sum[x] = (sum[(x << 1)] + sum[(x << 1 | 1)]) % P;
}
void Add(int &x, int y, int l, int r, int ql, int qr) {
  if (!x) {
    x = ++cnt;
    si[x] = 0;
  }
  if (si[x] == r - l + 1) return;
  if (l == ql && r == qr && si[x] == 0) {
    si[x] = r - l + 1;
    set_t1(y, Ni);
    set_t2(y, 1, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(y, l, r);
  if (qr <= mid)
    Add(ch[x][0], y << 1, l, mid, ql, qr);
  else if (ql > mid)
    Add(ch[x][1], y << 1 | 1, mid + 1, r, ql, qr);
  else
    Add(ch[x][0], y << 1, l, mid, ql, mid),
        Add(ch[x][1], y << 1 | 1, mid + 1, r, mid + 1, qr);
  si[x] = si[ch[x][0]] + si[ch[x][1]];
  sum[y] = (sum[y << 1] + sum[y << 1 | 1]) % P;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1, t, l, r, x; i <= q; ++i) {
    scanf("%d%d%d", &t, &l, &r);
    if (t == 1) {
      scanf("%d", &x);
      Modify(1, 1, n, l, r);
      Add(rt[x], 1, 1, n, l, r);
    } else {
      printf("%d\n", Query(1, 1, n, l, r));
    }
  }
  return 0;
}
