This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://judge.yosupo.jp/problem/point_set_range_composite"
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 998244353LL;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
#define call_from_test
#include "../DataStructure/SegmentTree.cpp"
#include "../Math/Modint.cpp"
#undef call_from_test
struct T {
mint a, b;
inline static T id() {
return T{1, 0};
}
inline static T f(const T &x, const T &y) {
return T{x.a * y.a, y.a * x.b + y.b};
}
inline static T g(const T &a, const T &b) {
return b;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n, q;
cin >> n >> q;
Segtree<T> seg(n);
for (int i = 0; i < n; i++) {
ll a, b;
cin >> a >> b;
seg.upd(i, T{a, b});
}
while (q--) {
int t;
cin >> t;
if (t == 0) {
int p, c, d;
cin >> p >> c >> d;
seg.upd(p, T{c, d});
} else {
int l, r;
cin >> l >> r;
T t = seg.get(l, r);
ll x;
cin >> x;
cout << (t.a * x + t.b) << '\n';
}
}
}
#line 1 "Test/SegmentTree.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/point_set_range_composite"
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 998244353LL;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
#define call_from_test
#line 1 "DataStructure/SegmentTree.cpp"
//@docs Docs/SegmentTree.md
template <class T>
struct Segtree {
int n;
vector<T> dat;
Segtree(int n_) {
n = 1;
while (n < n_) {
n <<= 1;
}
dat.resize(2 * n, T::id());
}
Segtree(int n_, const vector<T> &a) {
n = 1;
while (n < n_) {
n <<= 1;
}
dat.resize(2 * n, T::id());
for (int i = 0; i < a.size(); i++) {
dat[i + n] = a[i];
}
for (int i = n - 1; i > 0; i--) {
dat[i] = T::f(dat[i << 1], dat[i << 1 | 1]);
}
}
void upd(int k, const T &x) {
k += n;
dat[k] = T::g(dat[k], x);
k >>= 1;
while (k > 0) {
dat[k] = T::f(dat[k << 1], dat[k << 1 | 1]);
k >>= 1;
}
}
T get(const int &a, const int &b, int k, int l, int r) {
if (b <= l || r <= a) {
return T::id();
}
if (a <= l && r <= b) {
return dat[k];
}
return T::f(get(a, b, k << 1, l, (l + r) >> 1),
get(a, b, k << 1 | 1, (l + r) >> 1, r));
}
inline T get(const int &a, const int &b) { //[a,b)
if (a >= b) {
return T::id();
}
return get(a, b, 1, 0, n);
}
int find(const int &a, const int &b, const T &x, int k, int l, int r) {
if (b <= l || r <= a || dat[k] > x) {
return -1;
}
if (k >= n) {
return k - n;
}
int il = find(a, b, x, k << 1, l, (l + r) >> 1);
if (il != -1) {
return il;
}
return find(a, b, x, k << 1 | 1, (l + r) >> 1, r);
}
inline int find(const int &a, const int &b, const T &x) { //[a,b)における、値<=x なる最左のindexを求める
if (a >= b) {
return -1;
}
return find(a, b, x, 1, 0, n);
}
};
#line 1 "Math/Modint.cpp"
//from http://noshi91.hatenablog.com/entry/2019/03/31/174006
template <std::uint_fast64_t Modulus>
class modint {
using u64 = std::uint_fast64_t;
public:
u64 a;
constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint operator^(const u64 rhs) const noexcept {
return modint(*this) ^= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
constexpr modint &operator^=(u64 exp) {
modint rhs = modint(*this);
a = 1;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
friend ostream &operator<<(ostream &os, const modint &x) {
os << x.a;
return os;
}
friend istream &operator>>(istream &is, modint &x) {
is >> x.a;
return is;
}
};
using mint = modint<MOD>;
#line 28 "Test/SegmentTree.test.cpp"
#undef call_from_test
struct T {
mint a, b;
inline static T id() {
return T{1, 0};
}
inline static T f(const T &x, const T &y) {
return T{x.a * y.a, y.a * x.b + y.b};
}
inline static T g(const T &a, const T &b) {
return b;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n, q;
cin >> n >> q;
Segtree<T> seg(n);
for (int i = 0; i < n; i++) {
ll a, b;
cin >> a >> b;
seg.upd(i, T{a, b});
}
while (q--) {
int t;
cin >> t;
if (t == 0) {
int p, c, d;
cin >> p >> c >> d;
seg.upd(p, T{c, d});
} else {
int l, r;
cin >> l >> r;
T t = seg.get(l, r);
ll x;
cin >> x;
cout << (t.a * x + t.b) << '\n';
}
}
}