#include using namespace std; #define ALL(x) (x).begin(),(x).end() #define IO ios::sync_with_stdio(false),cin.tie(nullptr); #define LB(v, x) (ll)(lower_bound(ALL(v),x)-(v).begin()) #define UQ(v) sort(ALL(v)),(v).erase(unique(ALL(v)),v.end()) #define REP(i, n) for(ll i=0; i<(ll)(n); i++) #define FOR(i, a, b) for(ll i=(ll)(a); (a)<(b) ? i<(b) : i>(b); i+=((a)<(b) ? 1 : -1)) #define chmax(a, b) ((a)<(b) ? ((a)=(b), 1) : 0) #define chmin(a, b) ((a)>(b) ? ((a)=(b), 1) : 0) template using rpriority_queue=priority_queue,greater>; using ll=long long; const int INF=1e9+10; const ll INFL=4e18; using ld=long double; using ull=uint64_t; using LL=__int128_t; using VI=vector; using VVI=vector; using VL=vector; using VVL=vector; using PL=pair; using VP=vector; using WG=vector>>; template struct SegTreeDyanamic { using Type=typename Monoid::Type; struct Node { Type value; array to; ll left,right; Node(ll l, ll r) { to.fill(-1); left=l; right=r; } }; vector node; ll mx=1e9; vector route; SegTreeDyanamic(ll mx=1e9, int q=5e5) { this->mx=mx; node.reserve(q); node.push_back(Node(0,mx)); route.reserve(100); } void set(ll i, Type v) { ll left=0,right=mx,cur=0; route.clear(); while(left Type { if(rightr) return Monoid::id(); if(l<=left&&right<=r) return node[idx].value; ll mid=(left+right)/2; int leftc=node[idx].to[0],rightc=node[idx].to[1]; Type leftv,rightv; if(leftc==-1) leftv=Monoid::id(); else leftv=dfs(dfs,leftc,left,mid); if(rightc==-1) rightv=Monoid::id(); else rightv=dfs(dfs,rightc,mid,right); return Monoid::op(leftv,rightv); }; return dfs(dfs,0,0,mx); } }; /// @brief ModInt template struct ModInt{ ModInt(ll x=0){ value=(x>=0?x%MOD:MOD-(-x)%MOD); } ModInt operator-() const { return ModInt(-value); } ModInt operator+() const { return ModInt(*this); } ModInt& operator+=(const ModInt& other) { value+=other.value; if(value>=MOD) value-=MOD; return*this; } ModInt& operator-=(const ModInt& other) { value+=MOD-other.value; if(value>=MOD) value-=MOD; return*this; } ModInt& operator*=(const ModInt other) { value=value*other.value%MOD; return*this; } ModInt& operator/=(ModInt other) { (*this)*=other.inv(); return*this; } ModInt operator+(const ModInt& other) const { return ModInt(*this)+=other; } ModInt operator-(const ModInt& other) const { return ModInt(*this)-=other; } ModInt operator*(const ModInt& other) const { return ModInt(*this)*=other; } ModInt operator/(const ModInt& other) const { return ModInt(*this)/=other; } bool operator==(const ModInt& other) const { return value==other.value; } bool operator!=(const ModInt& other) const { return value!=other.value; } friend ostream& operator<<(ostream& os, const ModInt& x) { return os<>(istream& is, ModInt& x) { ll v; is>>v; x=ModInt(v); return is; } ModInt pow(ll x) const { ModInt ret(1),mul(value); while(x) { if(x&1) ret*=mul; mul*=mul; x>>=1; } return ret; } ModInt inv() const { return pow(MOD-2); } ll val() {return value; } static constexpr ll get_mod() { return MOD; } private: ll value; }; using Mod998=ModInt<998244353>; using Mod107=ModInt<1000000007>; using VM=vector; using mint=Mod998; //---------------------------------------------------------- struct Mon { using Type=pair; static Type op(Type l, Type r) { l.first=l.first*r.first; l.second=r.first*l.second+r.second; return l; } static Type id() { return { mint(1), mint(0) }; } }; int main() { IO; ll N,Q; cin>>N>>Q; SegTreeDyanamic seg(N); while(Q--) { int t; cin>>t; if(t==0) { ll p,c,d; cin>>p>>c>>d; seg.set(p,{c,d}); } else { ll l,r,x; cin>>l>>r>>x; auto [a,b]=seg.fold(l,r); mint ans=a*x+b; cout<