#pragma GCC optimize("Ofast") #include using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); ++i) #define all(x) x.begin(),x.end() #define ln '\n' const long double PI = acos(-1.0L); const long long MOD = 1000000007LL; // const long long MOD = 998244353LL; typedef long long ll; typedef pair pii; typedef pair pll; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; } //////////////////////////////////////////////////////////////////////////////////////////////////////////// template struct LazySegmentTree { int N; vector node,lazy; LazySegmentTree() = default; LazySegmentTree(vector &v) {init(v);} void init(vector &v) { int sz = v.size(); N = 1; while (N < sz) N *= 2; node.assign(2*N,0); lazy.assign(2*N,0); for (int i = 0; i < sz; i++) node[i+N] = v[i]; for (int i = N-1; i >= 1; i--) node[i] = node[i<<1|0] + node[i<<1|1]; } void eval(int k) { if (lazy[k] != 0) { node[k] += lazy[k]; if (k < N) { lazy[k<<1|0] += lazy[k]/2; lazy[k<<1|1] += lazy[k]/2; } lazy[k] = 0; } } void update(int a, int b, T val, int k = 1, int l = 0, int r = -1) { // [a,b) (0-indexed) if (r < 0) r = N; eval(k); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] += (r-l) * val; eval(k); } else { update(a, b, val, k<<1|0, l, (l+r)/2); update(a, b, val, k<<1|1, (l+r)/2, r); node[k] = node[k<<1|0] + node[k<<1|1]; } } T get(int a, int b, int k = 1, int l = 0, int r = -1) { // [a,b) (0-indexed) if (r < 0) r = N; eval(k); if (b <= l || r <= a) return 0; if (a <= l && r <= b) return node[k]; T vl = get(a, b, k<<1|0, l, (l+r)/2); T vr = get(a, b, k<<1|1, (l+r)/2, r); return vl + vr; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,Q; cin >> N >> Q; vector A(N); rep(i,N) cin >> A[i]; vector cnt(N),B(N); LazySegmentTree seg(cnt); rep(i,Q) { char c; ll x,y; cin >> c >> x >> y; if (c=='A') { --x; ll k = seg.get(x,x+1); B[x] += k*A[x]; seg.update(x,x+1,-k); A[x] += y; } else { --x; seg.update(x,y,1); } } rep(i,N) { ll k = seg.get(i,i+1); B[i] += k*A[i]; } rep(i,N) cout << B[i] << " "; cout << ln; }