#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10;   const int MOD = 998244353;   int n, q;   long long seg[4 * MAXN], mul[4 * MAXN], plu[4 * MAXN];   set<pair<int, int>> number[MAXN];   void shift(int l, int r, int id) {     int mid = l + r >> 1;     seg[id << 1] = (seg[id << 1] * mul[id]) % MOD;     seg[id << 1] = (seg[id << 1] + plu[id] * (mid - l)) % MOD;     seg[id << 1 | 1] = (seg[id << 1 | 1] * mul[id]) % MOD;     seg[id << 1 | 1] = (seg[id << 1 | 1] + plu[id] * (r - mid)) % MOD;     mul[id << 1] = (mul[id << 1] * mul[id]) % MOD;     plu[id << 1] = (plu[id << 1] * mul[id]) % MOD;     mul[id << 1 | 1] = (mul[id << 1 | 1] * mul[id]) % MOD;     plu[id << 1 | 1] = (plu[id << 1 | 1] * mul[id]) % MOD;     plu[id << 1] = (plu[id << 1] + plu[id]) % MOD;     plu[id << 1 | 1] = (plu[id << 1 | 1] + plu[id]) % MOD;     mul[id] = 1;     plu[id] = 0;   }   long long seg_get(int s, int e, int l = 0, int r = n, int id = 1) {     if (l >= s && r <= e) return seg[id];     if (l >= e || r <= s) return 0;     shift(l, r, id);     int mid = l + r >> 1;     return (seg_get(s, e, l, mid, id << 1) + seg_get(s, e, mid, r, id << 1 | 1)) %            MOD;   }   void seg_do(int s, int e, int l = 0, int r = n, int id = 1) {     if (l >= s && r <= e) {       seg[id] = (seg[id] + (r - l)) % MOD;       plu[id] = (plu[id] + 1) % MOD;       return;     }     if (l >= e || r <= s) return;     int mid = l + r >> 1;     shift(l, r, id);     seg_do(s, e, l, mid, id << 1);     seg_do(s, e, mid, r, id << 1 | 1);     seg[id] = (seg[id << 1] + seg[id << 1 | 1]) % MOD;     return;   }   void seg_mul(int s, int e, int l = 0, int r = n, int id = 1) {     if (s == e) return;     if (l >= s && r <= e) {       seg[id] = (seg[id] * 2) % MOD;       plu[id] = (plu[id] * 2) % MOD;       mul[id] = (mul[id] * 2) % MOD;       return;     }     if (l >= e || r <= s) return;     int mid = l + r >> 1;     shift(l, r, id);     seg_mul(s, e, l, mid, id << 1);     seg_mul(s, e, mid, r, id << 1 | 1);     seg[id] = (seg[id << 1] + seg[id << 1 | 1]) % MOD;     return;   }   void handle(int l, int r, int x) {     auto itl = number[x].upper_bound({l, -2});     itl--;     if ((*itl).second <= l) itl++;     auto itr = number[x].lower_bound({r, -2});     if ((*itl).first > l) {       seg_do(l, min(r, (*itl).first));     }     for (auto it = itl; it != itr; it++) {       int L = max(l, (*it).first);       int R = min(r, (*it).second);       seg_mul(L, R);       if ((*it).second >= r) continue;       auto it2 = it;       it2++;       L = (*it).second;       R = r;       R = min(R, (*it2).first);       seg_do(L, R);     }     l = min(l, (*itl).first);     itr--;     r = max(r, (*itr).second);     itr++;     number[x].erase(itl, itr);     number[x].insert({l, r});   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> q;     for (int i = 0; i < 4 * MAXN; i++) mul[i] = 1;     for (int i = 0; i <= n; i++) {       number[i].insert({-1, -1});       number[i].insert({n, n});     }     while (q--) {       int tp;       cin >> tp;       if (tp == 1) {         int l, r, x;         cin >> l >> r >> x;         handle(l - 1, r, x);       } else {         int l, r;         cin >> l >> r;         cout << seg_get(l - 1, r) <<   n ;       }     }     cin >> n;     return 0;   }