//#include #include using namespace std; typedef long long ll; typedef pair p; const int INF = 1e9; const ll LINF = ll(1e18) + 1; const int MOD = 1000000007; const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() #define debug(v) \ cout << #v << ":"; \ for (auto x : v) \ { \ cout << x << ' '; \ } \ cout << endl; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //cout< a; //区間和 struct LazySegmentTree { private: int n; vector node, lazy; public: LazySegmentTree(vector v) { int sz = (int)v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1); lazy.resize(2*n-1, 0); for(int i=0; i=0; i--) node[i] = node[i*2+1] + node[i*2+2]; } void eval(int k, int l, int r) { if(lazy[k] != 0) { node[k] += lazy[k]; if(r - l > 1) { lazy[2*k+1] += lazy[k] / 2; lazy[2*k+2] += lazy[k] / 2; } lazy[k] = 0; } } void add(int a, int b, ll x, int k=0, int l=0, int r=-1) { if(r < 0) r = n; eval(k, l, r); if(b <= l || r <= a) return; if(a <= l && r <= b) { lazy[k] += (r - l) * x; eval(k, l, r); } else { add(a, b, x, 2*k+1, l, (l+r)/2); add(a, b, x, 2*k+2, (l+r)/2, r); node[k] = node[2*k+1] + node[2*k+2]; } } ll getsum(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; eval(k, l, r); if(b <= l || r <= a) return 0; if(a <= l && r <= b) return node[k]; ll vl = getsum(a, b, 2*k+1, l, (l+r)/2); ll vr = getsum(a, b, 2*k+2, (l+r)/2, r); return vl + vr; } }; /* int main() { cin >> N >> Q; LazySegmentTree seg( vector(N, 0) ); for(int i=0; i> query; if(query == 0) { int s, t, x; cin >> s >> t >> x; seg.add(s-1, t, x); } else { int s, t; cin >> s >> t; cout << seg.getsum(s-1, t) << endl; } } return 0; } */ int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n>>q; LazySegmentTree seg( vector(n, 0) ); for (int i = 0; i < n; i++) { ll temp; cin >> temp; a.push_back(temp); seg.add(i,i+1,a[i]); //cout< b(n,0); LazySegmentTree segb( vector(n, 0) ); rep(i,q){ char flag; cin>>flag; ll x,y; cin>>x>>y; if(flag=='A'){ ll temp=segb.getsum(x-1,x); b[x-1]+=temp*a[x-1]; a[x-1]=y+a[x-1]; segb.add(x-1,x,-segb.getsum(x-1,x)); } else{ segb.add(x-1,y,1); } } for(int i=1;i<=n;i++){ ll temp=segb.getsum(i-1,i); b[i-1]+=a[i-1]*temp; } rep(i,n) cout << b[i] << "\n"; }