#include <bits/stdc++.h>
using namespace std;
const int N = 200500, mod = 998244353;
int n, q;
long long mul[4 * N], add[4 * N], sum[4 * N];
map<int, int> M[N];
void propagate(int x, int l, int r) {
  int mid = (l + r) / 2;
  sum[x * 2 + 1] = (sum[x * 2 + 1] * mul[x] + add[x] * (mid - l + 1)) % mod;
  sum[x * 2 + 2] = (sum[x * 2 + 2] * mul[x] + add[x] * (r - mid)) % mod;
  mul[x * 2 + 1] = mul[x * 2 + 1] * mul[x] % mod;
  mul[x * 2 + 2] = mul[x * 2 + 2] * mul[x] % mod;
  add[x * 2 + 1] = (add[x * 2 + 1] * mul[x] + add[x]) % mod;
  add[x * 2 + 2] = (add[x * 2 + 2] * mul[x] + add[x]) % mod;
  mul[x] = 1;
  add[x] = 0;
}
long long query(int a, int b, int x, int l, int r) {
  int mid = (l + r) / 2;
  if (r < a || l > b) return 0;
  if (l < r) propagate(x, l, r);
  if (l >= a && r <= b) {
    return sum[x];
  }
  long long LHS = query(a, b, x * 2 + 1, l, mid);
  long long RHS = query(a, b, x * 2 + 2, mid + 1, r);
  return (LHS + RHS) % mod;
}
void update(int a, int b, int x, int l, int r, int type) {
  int mid = (l + r) / 2;
  if (r < a || l > b) return;
  if (l < r) propagate(x, l, r);
  if (l >= a && r <= b) {
    if (type == 1) {
      sum[x] = (sum[x] + r - l + 1) % mod;
      add[x] = (add[x] + 1) % mod;
    } else {
      sum[x] = (sum[x] * 2) % mod;
      mul[x] = (mul[x] * 2) % mod;
    }
    return;
  }
  update(a, b, x * 2 + 1, l, mid, type);
  update(a, b, x * 2 + 2, mid + 1, r, type);
  sum[x] = (sum[x * 2 + 1] + sum[x * 2 + 2]) % mod;
}
void update(int l, int r, int type) { update(l, r, 0, 0, n - 1, type); }
void print_out(map<int, int> &mp) {
  cout << "map elements: ";
  for (auto p : mp) printf("[%d, %d], ", p.second, p.first);
  cout << endl;
}
void upd(int x, int l, int r) {
  auto &mp = M[x];
  auto it = mp.lower_bound(l);
  int las = l - 1;
  for (; it != mp.end();) {
    int nl = it->second, nr = it->first;
    if (nl > r) break;
    it = mp.erase(it);
    if (nl <= l - 1) mp[l - 1] = nl;
    if (nr >= r + 1) mp[nr] = r + 1;
    if (las + 1 <= nl - 1) update(las + 1, nl - 1, 1);
    nr = min(r, nr), nl = max(l, nl);
    update(nl, nr, 2);
    las = nr;
  }
  if (las + 1 <= r) update(las + 1, r, 1);
  mp[r] = l;
}
int main() {
  fill(mul, mul + 4 * N, 1);
  scanf("%d%d", &n, &q);
  while (q--) {
    int t, l, r, x;
    scanf("%d%d%d", &t, &l, &r);
    l--, r--;
    if (t == 1) {
      scanf("%d", &x);
      upd(x, l, r);
    } else {
      printf("%I64d\n", query(l, r, 0, 0, n - 1));
    }
  }
}
