#include #include using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } struct S { long long lmax; long long rmax; long long max; long long sum; }; S op(S a, S b) { return S{ max(a.lmax, a.sum + b.lmax), max(b.rmax, b.sum + a.rmax), max(max(a.max, b.max), a.rmax + b.lmax), a.sum + b.sum }; } S e() { return S{ -LINF, -LINF, -LINF, 0 }; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vectora(n), b(n), sb(n + 1); rep(i, n)cin >> a[i] >> b[i]; rep(i, n)sb[i + 1] = sb[i] + b[i]; vectortmp = { 0 }; rep(i, n) { tmp.push_back(sb[i + 1]); } int q; cin >> q; vectort(q), l(q), r(q); rep(i, q) { cin >> t[i] >> l[i] >> r[i]; l[i]--; if (1 == t[i]) { tmp.push_back(l[i]); } else { tmp.push_back(l[i]); tmp.push_back(r[i]); } } sort(all(tmp)); tmp.erase(unique(all(tmp)), tmp.end()); int sz = tmp.size(); segtreeseg(sz - 1); auto set = [&](int idx, long long sz, long long val)->void { if (val >= 0) { seg.set(idx, { sz* val, sz*val, sz*val, sz*val }); } else { seg.set(idx, { val, val, val, sz*val }); } }; rep(i, sz - 1) { long long sz = tmp[i + 1] - tmp[i]; int idx = upper_bound(all(sb), tmp[i]) - sb.begin(); set(i, sz, a[idx - 1]); } rep(i, q) { if (1 == t[i]) { int idx = lower_bound(all(tmp), l[i]) - tmp.begin(); set(idx, 1, r[i]); } else { int idxl = lower_bound(all(tmp), l[i]) - tmp.begin(); int idxr = lower_bound(all(tmp), r[i]) - tmp.begin(); auto get = seg.prod(idxl, idxr); cout << get.max << endl; } } return 0; }