#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";
    }
  }
}

### Prompt

Please provide a cpp coded solution to the problem described below:

In the School of Magic in Dirtpolis a lot of interesting objects are studied on Computer Science lessons.

Consider, for example, the magic multiset. If you try to add an integer to it that is already presented in the multiset, each element in the multiset duplicates. For example, if you try to add the integer 2 to the multiset \{1, 2, 3, 3\}, you will get \{1, 1, 2, 2, 3, 3, 3, 3\}. 

If you try to add an integer that is not presented in the multiset, it is simply added to it. For example, if you try to add the integer 4 to the multiset \{1, 2, 3, 3\}, you will get \{1, 2, 3, 3, 4\}.

Also consider an array of n initially empty magic multisets, enumerated from 1 to n.

You are to answer q queries of the form "add an integer x to all multisets with indices l, l + 1, …, r" and "compute the sum of sizes of multisets with indices l, l + 1, …, r". The answers for the second type queries can be large, so print the answers modulo 998244353.

Input

The first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^{5}) — the number of magic multisets in the array and the number of queries, respectively.

The next q lines describe queries, one per line. Each line starts with an integer t (1 ≤ t ≤ 2) — the type of the query. If t equals 1, it is followed by three integers l, r, x (1 ≤ l ≤ r ≤ n, 1 ≤ x ≤ n) meaning that you should add x to all multisets with indices from l to r inclusive. If t equals 2, it is followed by two integers l, r (1 ≤ l ≤ r ≤ n) meaning that you should compute the sum of sizes of all multisets with indices from l to r inclusive.

Output

For each query of the second type print the sum of sizes of multisets on the given segment.

The answers can be large, so print them modulo 998244353.

Examples

Input

4 4
1 1 2 1
1 1 2 2
1 1 4 1
2 1 4


Output

10


Input

3 7
1 1 1 3
1 1 1 3
1 1 1 2
1 1 1 1
2 1 1
1 1 1 2
2 1 1


Output

4
8

Note

In the first example after the first two queries the multisets are equal to [\{1, 2\},\{1, 2\},\{\},\{\}], after the third query they are equal to [\{1, 1, 2, 2\},\{1, 1, 2, 2\},\{1\},\{1\}].

In the second example the first multiset evolves as follows: 

\{\} → \{3\} → \{3, 3\} → \{2, 3, 3\} → \{1, 2, 3, 3\} → \{1, 1, 2, 2, 3, 3, 3, 3\}. 

### Response

```cpp
#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";
    }
  }
}

```