#pragma GCC optimization ("O3") #include using namespace std; using ll = long long; using vec = vector; using mat = vector; using pll = pair; #define INF (1LL<<61) #define MOD 1000000007LL // #define MOD 998244353LL #define EPS (1e-10) #define PR(x) cout << (x) << endl #define PS(x) cout << (x) << " " #define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i)) #define FORE(i,v) for(auto (i):v) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((ll)(x).size()) #define REV(x) reverse(ALL((x))) #define ASC(x) sort(ALL((x))) #define DESC(x) {ASC((x)); REV((x));} #define BIT(s,i) (((s)>>(i))&1) #define pb push_back #define fi first #define se second template inline int chmin(T& a, T b) {if(a>b) {a=b; return 1;} return 0;} template inline int chmax(T& a, T b) {if(a=MOD) x-=MOD; return *this;} mint& operator-=(const mint& a) {if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;} mint& operator*=(const mint& a) {(x*=a.x)%=MOD; return *this;} mint operator+(const mint& a) const {mint b(*this); return b+=a;} mint operator-(const mint& a) const {mint b(*this); return b-=a;} mint operator*(const mint& a) const {mint b(*this); return b*=a;} mint pow(ll t) const {if(!t) return 1; mint a=pow(t>>1); return (t&1?*this*a:a)*a;} mint inv() const {return pow(MOD-2);} mint& operator/=(const mint& a) {return *this*=a.inv();} mint operator/(const mint& a) const {mint b(*this); return b/=a;} }; istream &operator>>(istream& is, mint& a) {ll t; is>>t; a=t; return is;} ostream &operator<<(ostream& os, const mint& a) {return os< struct LazySegmentTree { using FX = function; using FA = function; using FM = function; int n; // (1) f[m](x1*x2) = f[m](x1)*f[m](x2) // (2) f[m2](f[m1](x)) = (f[m2]@f[m1])(x) FX fx; // x1*x2 FA fa; // f[m](x) FM fm; // f[m2]@f[m1] const X ex; // e const M em; // id vector dat; vector lazy; LazySegmentTree(int n_, FX fx_, FA fa_, FM fm_, X ex_, M em_) : n(), fx(fx_), fa(fa_), fm(fm_), ex(ex_), em(em_) { int x = 1; while(n_ > x) x *= 2; n = x; dat = vector(n*2, ex); lazy = vector(n*2, em); } void set(int i, X x) { dat[i+n-1] = x; } void build() { for (int k=n-2; k>=0; k--) dat[k] = fx(dat[k*2+1], dat[k*2+2]); } void eval(int k) { if(lazy[k] == em) return; if(k < n-1) { lazy[k*2+1] = fm(lazy[k*2+1], lazy[k]); lazy[k*2+2] = fm(lazy[k*2+2], lazy[k]); } dat[k] = fa(dat[k], lazy[k]); lazy[k] = em; } void update_sub(int a, int b, M m, int k, int l, int r) { eval(k); if(a <= l && r <= b) { lazy[k] = fm(lazy[k], m); eval(k); } else if(a < r && l < b) { update_sub(a, b, m, k*2+1, l, (l+r)/2); update_sub(a, b, m, k*2+2, (l+r)/2, r); dat[k] = fx(dat[k*2+1], dat[k*2+2]); } } void update(int a, int b, M m) { update_sub(a, b, m, 0, 0, n); } X output_sub(int a, int b, int k, int l, int r) { eval(k); if(r <= a || b <= l) return ex; else if(a <= l && r <= b) return dat[k]; else { X vl = output_sub(a, b, k*2+1, l, (l+r)/2); X vr = output_sub(a, b, k*2+2, (l+r)/2, r); return fx(vl, vr); } } X output(int a, int b) { return output_sub(a, b, 0, 0, n); } }; int main() { ll N, Q; cin >> N >> Q; mat query; REP(i,1,N+1) { ll a; cin >> a; query.pb({0, i, a}); } REP(i,0,Q) { char c; ll x, y; cin >> c >> x >> y; query.pb({c == 'B', x, y}); } REV(query); pll ex = {0, 0}; ll em = 0; auto fx = [](pll l, pll r) -> pll {return {l.fi+r.fi, l.se+r.se};}; auto fa = [](pll x, ll f) -> pll {return {x.fi+x.se*f, x.se};}; auto fm = [](ll f, ll g) -> ll {return f+g;}; LazySegmentTree lst1(N+1, fx, fa, fm, ex, em), lst2(N+1, fx, fa, fm, ex, em); REP(i,0,N+1) lst1.set(i, {0, 1}), lst2.set(i, {0, 1}); lst1.build(); lst2.build(); FORE(q,query) { ll t = q[0], x = q[1], y = q[2]; if(t == 0) lst1.update(x, x+1, y*lst2.output(x, x+1).fi); else lst2.update(x, y+1, 1); } REP(i,1,N+1) PS(lst1.output(i,i+1).fi); PR(""); return 0; } /* */