#include <bits/stdc++.h>
using namespace std;
int n, q, ta, l, r, x, rt[200005];
vector<pair<int, int> > tr;
vector<long long> mm[19], ii[19], aa[19], zz[19];
inline void add(long long &a, long long b) {
  a += b;
  if (a >= 998244353) a -= 998244353;
}
inline void lazy(int e, int f) {
  if (zz[e + 1][f / 2]) {
    long long tt = zz[e + 1][f / 2] * ii[e][f] % 998244353;
    add(zz[e][f], tt);
    aa[e][f] = (aa[e][f] + (tt << e)) % 998244353;
    if (f + 1 < aa[e].size()) {
      tt = zz[e + 1][f / 2] * ii[e][f + 1] % 998244353;
      add(zz[e][f + 1], tt);
      aa[e][f + 1] = (aa[e][f + 1] + (tt << e)) % 998244353;
    }
    zz[e + 1][f / 2] = 0;
  }
  if (mm[e + 1][f / 2] != 1) {
    mm[e][f] = mm[e][f] * mm[e + 1][f / 2] % 998244353;
    ii[e][f] = ii[e][f] * ii[e + 1][f / 2] % 998244353;
    if (f + 1 < mm[e].size()) {
      mm[e][f + 1] = mm[e][f + 1] * mm[e + 1][f / 2] % 998244353;
      ii[e][f + 1] = ii[e][f + 1] * ii[e + 1][f / 2] % 998244353;
    }
    mm[e + 1][f / 2] = ii[e + 1][f / 2] = 1;
  }
}
inline bool ful(int a) { return tr[a].first == 0 && tr[a].second == 0; }
void f1(int a, int b, int c, int d, int e, int f, int g) {
  if (g != -1 && ful(g)) g = -1;
  int mi = (c + d) / 2;
  if (a == c && b == d) {
    if (g == -1) {
      mm[e][f] = mm[e][f] * 2 % 998244353;
      ii[e][f] = ii[e][f] * 499122177 % 998244353;
    } else {
      if (tr[g].first == -1) {
        tr[g].first = 0;
        aa[e][f] = (aa[e][f] + (ii[e][f] << e)) % 998244353;
        add(zz[e][f], ii[e][f]);
      } else {
        e--;
        f = f * 2;
        lazy(e, f);
        if (tr[g].first == 0) {
          aa[e][f] = (aa[e][f] + (ii[e][f] << e)) % 998244353;
          add(zz[e][f], ii[e][f]);
        } else {
          f1(a, mi, a, mi, e, f, tr[g].first);
          tr[g].first = 0;
        }
        if (tr[g].second == 0) {
          aa[e][f + 1] = (aa[e][f + 1] + (ii[e][f + 1] << e)) % 998244353;
          add(zz[e][f + 1], ii[e][f + 1]);
        } else {
          f1(mi, b, mi, b, e, f + 1, tr[g].second);
          tr[g].second = 0;
        }
        aa[e + 1][f / 2] =
            (aa[e][f] * mm[e][f] + aa[e][f + 1] * mm[e][f + 1]) % 998244353;
      }
    }
    return;
  }
  e--;
  f = f * 2;
  lazy(e, f);
  if (g == -1) {
    if (a < mi) f1(a, min(b, mi), c, mi, e, f, -1);
    if (b > mi) f1(max(a, mi), b, mi, d, e, f + 1, -1);
  } else {
    if (tr[g].first == -1) tr[g].first = 0;
    if (a < mi) {
      if (!tr[g].first) {
        tr[g].first = tr.size();
        tr.push_back({-1, 0});
      }
      f1(a, min(b, mi), c, mi, e, f, tr[g].first);
    }
    if (b > mi) {
      if (!tr[g].second) {
        tr[g].second = tr.size();
        tr.push_back({-1, 0});
      }
      f1(max(a, mi), b, mi, d, e, f + 1, tr[g].second);
    }
    if (tr[g].first && ful(tr[g].first) && tr[g].second && ful(tr[g].second))
      tr[g].first = tr[g].second = 0;
  }
  aa[e + 1][f / 2] = aa[e][f] * mm[e][f] % 998244353;
  if (f + 1 < aa[e].size())
    aa[e + 1][f / 2] =
        (aa[e + 1][f / 2] + aa[e][f + 1] * mm[e][f + 1]) % 998244353;
}
long long f2(int a, int b, int e, int f) {
  if (a == ((1 << (e)) * (f)) && b == ((1 << (e)) * (f + 1)))
    return aa[e][f] * mm[e][f] % 998244353;
  e--;
  f = f * 2;
  lazy(e, f);
  long long re = 0;
  int mi = ((1 << (e)) * (f + 1));
  if (a < mi) re = f2(a, min(b, mi), e, f);
  if (b > mi) add(re, f2(max(a, mi), b, e, f + 1));
  aa[e + 1][f / 2] = aa[e][f] * mm[e][f] % 998244353;
  if (f + 1 < aa[e].size())
    aa[e + 1][f / 2] =
        (aa[e + 1][f / 2] + aa[e][f + 1] * mm[e][f + 1]) % 998244353;
  return re;
}
int main() {
  scanf("%d%d", &n, &q);
  mm[0] = vector<long long>(n, 1);
  ii[0] = vector<long long>(n, 1);
  aa[0] = vector<long long>(n, 0);
  zz[0] = vector<long long>(n, 0);
  for (int i = 1; i <= n; i++) rt[i] = -1;
  for (int i = 1; i < 19; i++) {
    mm[i] = vector<long long>((mm[i - 1].size() + 1) / 2, 1);
    ii[i] = vector<long long>((ii[i - 1].size() + 1) / 2, 1);
    aa[i] = vector<long long>((aa[i - 1].size() + 1) / 2, 0);
    zz[i] = vector<long long>((zz[i - 1].size() + 1) / 2, 0);
  }
  while (q--) {
    scanf("%d", &ta);
    if (ta == 1) {
      scanf("%d%d%d", &l, &r, &x);
      l--;
      if (rt[x] == -1) {
        rt[x] = tr.size();
        tr.push_back({-1, 0});
      }
      f1(l, r, 0, 1 << 18, 18, 0, rt[x]);
    } else {
      scanf("%d%d", &l, &r);
      l--;
      printf("%lld\n", f2(l, r, 18, 0));
    }
  }
  return 0;
}
