#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int md = 998244353;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
  unsigned long long x = (long long)a * b;
  unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
  asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(md));
  return m;
}
inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
class segtree {
 public:
  struct node {
    int val = 0;
    int ad = 0;
    int mu = 1;
    void apply(int l, int r, int x) {
      if (x >= 0) {
        add(ad, x);
        add(val, mul(x, r - l + 1));
      } else {
        x = ~x;
        val = mul(val, x);
        ad = mul(ad, x);
        mu = mul(mu, x);
      }
    }
  };
  node unite(const node &a, const node &b) {
    node res;
    res.val = a.val;
    add(res.val, b.val);
    return res;
  }
  inline void push(int x, int l, int r) {
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    if (tree[x].mu > 1) {
      tree[x + 1].apply(l, y, ~tree[x].mu);
      tree[z].apply(y + 1, r, ~tree[x].mu);
      tree[x].mu = 1;
    }
    if (tree[x].ad > 0) {
      tree[x + 1].apply(l, y, tree[x].ad);
      tree[z].apply(y + 1, r, tree[x].ad);
      tree[x].ad = 0;
    }
  }
  inline void pull(int x, int z) { tree[x] = unite(tree[x + 1], tree[z]); }
  int n;
  vector<node> tree;
  void build(int x, int l, int r) {
    if (l == r) {
      return;
    }
    int y = (r + l) >> 1;
    int z = x + ((y - l + 1) << 1);
    build(x + 1, l, y);
    build(z, y + 1, r);
    pull(x, z);
  }
  segtree(int _n) : n(_n) {
    assert(n > 0);
    tree.resize(2 * n - 1);
    build(0, 0, n - 1);
  }
  void modify(int x, int l, int r, int ll, int rr, int v) {
    if (ll <= l && r <= rr) {
      tree[x].apply(l, r, v);
      return;
    }
    push(x, l, r);
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    if (ll > y) {
      modify(z, y + 1, r, ll, rr, v);
    } else {
      if (rr <= y) {
        modify(x + 1, l, y, ll, rr, v);
      } else {
        modify(x + 1, l, y, ll, rr, v);
        modify(z, y + 1, r, ll, rr, v);
      }
    }
    pull(x, z);
  }
  void modify(int l, int r, int x) {
    assert(0 <= l && l <= r && r <= n - 1);
    modify(0, 0, n - 1, l, r, x);
  }
  node get(int x, int l, int r, int ll, int rr) {
    if (ll <= l && r <= rr) {
      return tree[x];
    }
    push(x, l, r);
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    node res{};
    if (ll > y) {
      res = get(z, y + 1, r, ll, rr);
    } else {
      if (rr <= y) {
        res = get(x + 1, l, y, ll, rr);
      } else {
        res = unite(get(z, y + 1, r, ll, rr), get(x + 1, l, y, ll, rr));
      }
    }
    pull(x, z);
    return res;
  }
  node get(int l, int r) {
    assert(0 <= l && l <= r && r <= n - 1);
    return get(0, 0, n - 1, l, r);
  }
};
int n, q;
int t, l, r, x;
vector<set<pair<int, int>>> cur;
int main() {
  scanf("%d%d", &n, &q);
  cur.resize(n);
  segtree res(n);
  while (q--) {
    scanf("%d%d%d", &t, &l, &r);
    l--;
    r--;
    if (t == 1) {
      scanf("%d", &x);
      x--;
      vector<pair<int, int>> pls, mlt;
      if (cur[x].size() == 0) {
        auto t = make_pair(l, r);
        res.modify(l, r, 1);
        cur[x].insert(t);
        continue;
      }
      auto iter = cur[x].lower_bound(make_pair(l, -1));
      if (iter != cur[x].begin()) iter--;
      for (auto it = iter; it != cur[x].end(); it++) {
        int u = it->first, v = it->second;
        if (u > r) break;
        int head = max(u, l), tail = min(v, r);
        if (head > tail) continue;
        mlt.push_back(make_pair(head, tail));
      }
      if (mlt.empty())
        pls.push_back(make_pair(l, r));
      else {
        if (mlt[0].first > l) pls.push_back(make_pair(l, mlt[0].first - 1));
        if (mlt.back().second < r)
          pls.push_back(make_pair(mlt.back().second + 1, r));
      }
      for (int i = 0; i < (int)mlt.size() - 1; i++) {
        pls.push_back(make_pair(mlt[i].second + 1, mlt[i + 1].first - 1));
      }
      auto memo = cur[x].end();
      for (auto it = iter; it != cur[x].end(); it++) {
        if (it->second < l - 1) {
          iter++;
          continue;
        }
        if (it->first > r + 1) {
          memo = it;
          break;
        }
        l = min(l, it->first);
        r = max(r, it->second);
      }
      cur[x].erase(iter, memo);
      cur[x].insert(make_pair(l, r));
      for (auto i : pls) {
        res.modify(i.first, i.second, 1);
      }
      for (auto i : mlt) {
        res.modify(i.first, i.second, ~2);
      }
    }
    if (t == 2) {
      printf("%d\n", res.get(l, r).val);
    }
  }
  return 0;
}

### Prompt

Your task is to create a Cpp solution to the following problem:

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;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int md = 998244353;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
  unsigned long long x = (long long)a * b;
  unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
  asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(md));
  return m;
}
inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
class segtree {
 public:
  struct node {
    int val = 0;
    int ad = 0;
    int mu = 1;
    void apply(int l, int r, int x) {
      if (x >= 0) {
        add(ad, x);
        add(val, mul(x, r - l + 1));
      } else {
        x = ~x;
        val = mul(val, x);
        ad = mul(ad, x);
        mu = mul(mu, x);
      }
    }
  };
  node unite(const node &a, const node &b) {
    node res;
    res.val = a.val;
    add(res.val, b.val);
    return res;
  }
  inline void push(int x, int l, int r) {
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    if (tree[x].mu > 1) {
      tree[x + 1].apply(l, y, ~tree[x].mu);
      tree[z].apply(y + 1, r, ~tree[x].mu);
      tree[x].mu = 1;
    }
    if (tree[x].ad > 0) {
      tree[x + 1].apply(l, y, tree[x].ad);
      tree[z].apply(y + 1, r, tree[x].ad);
      tree[x].ad = 0;
    }
  }
  inline void pull(int x, int z) { tree[x] = unite(tree[x + 1], tree[z]); }
  int n;
  vector<node> tree;
  void build(int x, int l, int r) {
    if (l == r) {
      return;
    }
    int y = (r + l) >> 1;
    int z = x + ((y - l + 1) << 1);
    build(x + 1, l, y);
    build(z, y + 1, r);
    pull(x, z);
  }
  segtree(int _n) : n(_n) {
    assert(n > 0);
    tree.resize(2 * n - 1);
    build(0, 0, n - 1);
  }
  void modify(int x, int l, int r, int ll, int rr, int v) {
    if (ll <= l && r <= rr) {
      tree[x].apply(l, r, v);
      return;
    }
    push(x, l, r);
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    if (ll > y) {
      modify(z, y + 1, r, ll, rr, v);
    } else {
      if (rr <= y) {
        modify(x + 1, l, y, ll, rr, v);
      } else {
        modify(x + 1, l, y, ll, rr, v);
        modify(z, y + 1, r, ll, rr, v);
      }
    }
    pull(x, z);
  }
  void modify(int l, int r, int x) {
    assert(0 <= l && l <= r && r <= n - 1);
    modify(0, 0, n - 1, l, r, x);
  }
  node get(int x, int l, int r, int ll, int rr) {
    if (ll <= l && r <= rr) {
      return tree[x];
    }
    push(x, l, r);
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    node res{};
    if (ll > y) {
      res = get(z, y + 1, r, ll, rr);
    } else {
      if (rr <= y) {
        res = get(x + 1, l, y, ll, rr);
      } else {
        res = unite(get(z, y + 1, r, ll, rr), get(x + 1, l, y, ll, rr));
      }
    }
    pull(x, z);
    return res;
  }
  node get(int l, int r) {
    assert(0 <= l && l <= r && r <= n - 1);
    return get(0, 0, n - 1, l, r);
  }
};
int n, q;
int t, l, r, x;
vector<set<pair<int, int>>> cur;
int main() {
  scanf("%d%d", &n, &q);
  cur.resize(n);
  segtree res(n);
  while (q--) {
    scanf("%d%d%d", &t, &l, &r);
    l--;
    r--;
    if (t == 1) {
      scanf("%d", &x);
      x--;
      vector<pair<int, int>> pls, mlt;
      if (cur[x].size() == 0) {
        auto t = make_pair(l, r);
        res.modify(l, r, 1);
        cur[x].insert(t);
        continue;
      }
      auto iter = cur[x].lower_bound(make_pair(l, -1));
      if (iter != cur[x].begin()) iter--;
      for (auto it = iter; it != cur[x].end(); it++) {
        int u = it->first, v = it->second;
        if (u > r) break;
        int head = max(u, l), tail = min(v, r);
        if (head > tail) continue;
        mlt.push_back(make_pair(head, tail));
      }
      if (mlt.empty())
        pls.push_back(make_pair(l, r));
      else {
        if (mlt[0].first > l) pls.push_back(make_pair(l, mlt[0].first - 1));
        if (mlt.back().second < r)
          pls.push_back(make_pair(mlt.back().second + 1, r));
      }
      for (int i = 0; i < (int)mlt.size() - 1; i++) {
        pls.push_back(make_pair(mlt[i].second + 1, mlt[i + 1].first - 1));
      }
      auto memo = cur[x].end();
      for (auto it = iter; it != cur[x].end(); it++) {
        if (it->second < l - 1) {
          iter++;
          continue;
        }
        if (it->first > r + 1) {
          memo = it;
          break;
        }
        l = min(l, it->first);
        r = max(r, it->second);
      }
      cur[x].erase(iter, memo);
      cur[x].insert(make_pair(l, r));
      for (auto i : pls) {
        res.modify(i.first, i.second, 1);
      }
      for (auto i : mlt) {
        res.modify(i.first, i.second, ~2);
      }
    }
    if (t == 2) {
      printf("%d\n", res.get(l, r).val);
    }
  }
  return 0;
}

```