#include <bits/stdc++.h>
using namespace std;
int MOD = 998244353;
const long double E = 1e-9;
unsigned char ccc;
bool _minus = false;
template <typename T>
inline T sqr(T t) {
  return (t * t);
}
inline void read(long long &n) {
  n = 0;
  _minus = false;
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    if (ccc == '-') {
      _minus = true;
      continue;
    }
    n = n * 10 + ccc - '0';
  }
  if (_minus) n *= -1;
}
inline bool read(int &n) {
  n = 0;
  _minus = false;
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') {
      if (ccc == '\n') return true;
      break;
    }
    if (ccc == '-') {
      _minus = true;
      continue;
    }
    n = n * 10 + ccc - '0';
  }
  if (_minus) n *= -1;
  return false;
}
char wwww[19];
int kkkk;
inline void write(long long y) {
  long long x = y;
  kkkk = 0;
  if (x < 0) {
    putchar('-');
    x *= -1;
  }
  if (!x) {
    ++kkkk;
    wwww[kkkk] = '0';
  } else
    while (x) {
      ++kkkk;
      wwww[kkkk] = char(x % 10 + '0');
      x /= 10;
    }
  for (int i = kkkk; i >= 1; --i) putchar(wwww[i]);
}
const int MAX = 2e5 + 10;
set<pair<int, int> > s[MAX];
long long t[MAX << 4], hello_world[MAX << 4], y2[MAX << 4];
inline void push1(int v) {
  if (hello_world[v] > 1) {
    hello_world[v << 1] *= hello_world[v];
    hello_world[v << 1] %= MOD;
    hello_world[v << 1 | 1] *= hello_world[v];
    hello_world[v << 1 | 1] %= MOD;
    y2[v << 1] *= hello_world[v];
    y2[v << 1] %= MOD;
    y2[v << 1 | 1] *= hello_world[v];
    y2[v << 1 | 1] %= MOD;
    t[v << 1] *= hello_world[v];
    t[v << 1] %= MOD;
    t[v << 1 | 1] *= hello_world[v];
    t[v << 1 | 1] %= MOD;
    hello_world[v] = 1;
  }
}
inline void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}
inline void add_2(long long &a, long long b) {
  a += b;
  if (a >= MOD) {
    a %= MOD;
  }
}
inline void mult(long long &a, long long b) {
  a *= b;
  a %= MOD;
}
inline long long sum(long long a, long long b) {
  if (a + b >= MOD) {
    return a + b - MOD;
  } else {
    return a + b;
  }
}
inline void push2(int v, int l, int r) {
  if (y2[v]) {
    push1(v << 1);
    push1(v << 1 | 1);
    add(y2[v << 1], y2[v]);
    add(y2[v << 1 | 1], y2[v]);
    int x = (l + r) >> 1;
    add_2(t[v << 1], y2[v] * (x - l + 1));
    add_2(t[v << 1 | 1], y2[v] * (r - x));
    y2[v] = 0;
  }
}
void add_val(int v, int tl, int tr, int l, int r, int val) {
  if (tl > tr) {
    return;
  }
  push1(v);
  if (l <= tl && tr <= r) {
    add_2(t[v], val * 1LL * (tr - tl + 1));
    add(y2[v], val);
    return;
  }
  if (tr < l | r < tl) {
    return;
  }
  push2(v, tl, tr);
  int x = (tl + tr) >> 1;
  add_val(v << 1, tl, x, l, r, val);
  add_val(v << 1 | 1, x + 1, tr, l, r, val);
  t[v] = sum(t[v << 1], t[v << 1 | 1]);
}
void mult_val(int v, int tl, int tr, int l, int r, int val) {
  push1(v);
  if (l <= tl && tr <= r) {
    mult(t[v], val);
    mult(hello_world[v], val);
    mult(y2[v], val);
    return;
  }
  if (tr < l | r < tl) {
    return;
  }
  push2(v, tl, tr);
  int x = (tl + tr) >> 1;
  mult_val(v << 1, tl, x, l, r, val);
  mult_val(v << 1 | 1, x + 1, tr, l, r, val);
  t[v] = sum(t[v << 1], t[v << 1 | 1]);
}
int n, q;
long long get_sum(int v, int tl, int tr, int l, int r) {
  push1(v);
  if (l <= tl && tr <= r) {
    return t[v];
  }
  if (tr < l || r < tl) {
    return 0;
  }
  push2(v, tl, tr);
  int x = (tl + tr) >> 1;
  return sum(get_sum(v << 1, tl, x, l, r),
             get_sum(v << 1 | 1, x + 1, tr, l, r));
}
void add_val(int l, int r, int x) {
  if (l > r) return;
  if (0) cout << "# " << l << " " << r << " " << x << "\n";
  add_val(1, 1, n, l, r, x);
}
void mult_val(int l, int r, int x) {
  if (l > r) return;
  if (0) cout << "* " << l << " " << r << " " << x << "\n";
  mult_val(1, 1, n, l, r, x);
}
void __add(int l, int r, int x) {
  for (int i = l; i <= r;) {
    set<pair<int, int> >::iterator it = s[x].lower_bound(make_pair(l, -1));
    if (it == s[x].end() || it->second > r) {
      s[x].insert(make_pair(r, l));
      add_val(i, r, 1);
      return;
    }
    int L = it->second;
    int R = it->first;
    add_val(i, L - 1, 1);
    mult_val(max(i, L), min(r, R), 2);
    r = max(r, R);
    l = min(l, L);
    s[x].erase(it);
    i = R + 1;
  }
  s[x].insert(make_pair(r, l));
}
struct solve_long {
  set<int> s[1000];
  long long ans[1000];
  solve_long() {
    for (int i = 0; i < 1000; i++) {
      ans[i] = 0;
    }
  }
  void add(int l, int r, int x) {
    for (int i = l; i <= r; i++) {
      if (s[i].find(x) != s[i].end()) {
        ans[i] *= 2;
        ans[i] %= MOD;
      } else {
        s[i].insert(x);
        ans[i]++;
        ans[i] %= MOD;
      }
    }
  }
  long long sum(int l, int r) {
    long long ans = 0;
    for (int i = l; i <= r; i++) {
      ans += this->ans[i];
    }
    return ans % MOD;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  srand((unsigned int)time(NULL));
  cout.precision(10);
  cout << fixed;
  cin >> n >> q;
  for (int i = 0; i < (MAX << 4); i++) {
    hello_world[i] = 1;
  }
  solve_long sl;
  for (int i = 1; i <= q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r, x;
      cin >> l >> r >> x;
      if (0) sl.add(l, r, x);
      __add(l, r, x);
      if (0) {
        cout << x << ": ";
        for (auto a : s[x]) {
          cout << "[" << a.second << "," << a.first << "]";
        }
        cout << "\n";
      }
    } else {
      int l, r;
      cin >> l >> r;
      cout << get_sum(1, 1, n, l, r) << "\n";
      if (0) cout << "@@@ " << sl.sum(l, r) << "\n";
    }
  }
}
